<!DOCTYPE html>
<html lang="en-US" dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>基本概述 | VitePress</title>
    <meta name="description" content="A VitePress site">
    <link rel="preload stylesheet" href="/notebook/assets/style.3dbfd0c2.css" as="style">
    
    <script type="module" src="/notebook/assets/app.8aaa4cbe.js"></script>
    <link rel="preload" href="/notebook/assets/inter-roman-latin.2ed14f66.woff2" as="font" type="font/woff2" crossorigin="">
    <link rel="modulepreload" href="/notebook/assets/chunks/framework.1336c4e5.js">
    <link rel="modulepreload" href="/notebook/assets/chunks/theme.20cddc0c.js">
    <link rel="modulepreload" href="/notebook/assets/5、运维_Git.md.0264925c.lean.js">
    <script id="check-dark-light">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
  </head>
  <body>
    <div id="app"><div class="Layout" data-v-255ec12d><!--[--><!--]--><!--[--><span tabindex="-1" data-v-ae3e3f51></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-ae3e3f51> Skip to content </a><!--]--><!----><header class="VPNav" data-v-255ec12d data-v-7e5bc4a5><div class="VPNavBar has-sidebar" data-v-7e5bc4a5 data-v-0937f67c><div class="container" data-v-0937f67c><div class="title" data-v-0937f67c><div class="VPNavBarTitle has-sidebar" data-v-0937f67c data-v-86d1bed8><a class="title" href="/notebook/" data-v-86d1bed8><!--[--><!--]--><!--[--><img class="VPImage logo" src="/notebook/Vue.png" alt data-v-8426fc1a><!--]--><!--[-->任硕的文档<!--]--><!--[--><!--]--></a></div></div><div class="content" data-v-0937f67c><div class="curtain" data-v-0937f67c></div><div class="content-body" data-v-0937f67c><!--[--><!--]--><div class="VPNavBarSearch search" style="--vp-meta-key:&#39;Meta&#39;;" data-v-0937f67c><!--[--><!----><div id="docsearch"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><svg class="DocSearch-Search-Icon" width="20" height="20" viewBox="0 0 20 20" aria-label="search icon"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-0937f67c data-v-7f418b0f><span id="main-nav-aria-label" class="visually-hidden" data-v-7f418b0f>Main Navigation</span><!--[--><!--[--><div class="VPFlyout VPNavBarMenuGroup" data-v-7f418b0f data-v-a7b5672a><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-a7b5672a><span class="text" data-v-a7b5672a><!----><span data-v-a7b5672a>Java学前端</span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="text-icon" data-v-a7b5672a><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="menu" data-v-a7b5672a><div class="VPMenu" data-v-a7b5672a data-v-e7ea1737><div class="items" data-v-e7ea1737><!--[--><!--[--><div class="VPMenuGroup" data-v-e7ea1737 data-v-69e747b5><!----><!--[--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/Java%E5%AD%A6%E5%89%8D%E7%AB%AF/HTML+JS.html" data-v-2f2cfafc><!--[-->HTML+JS<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/Java%E5%AD%A6%E5%89%8D%E7%AB%AF/CSS.html" data-v-2f2cfafc><!--[-->CSS<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/Java%E5%AD%A6%E5%89%8D%E7%AB%AF/Vue2+%E7%BB%84%E4%BB%B6.html" data-v-2f2cfafc><!--[-->Vue2+组件<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/Java%E5%AD%A6%E5%89%8D%E7%AB%AF/Vue3+%E7%BB%84%E4%BB%B6.html" data-v-2f2cfafc><!--[-->Vue3+组件<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/Java%E5%AD%A6%E5%89%8D%E7%AB%AF/React.html" data-v-2f2cfafc><!--[-->React<!--]--></a></div><!--]--><!--]--></div><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--[--><div class="VPFlyout VPNavBarMenuGroup" data-v-7f418b0f data-v-a7b5672a><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-a7b5672a><span class="text" data-v-a7b5672a><!----><span data-v-a7b5672a>软件测试</span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="text-icon" data-v-a7b5672a><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="menu" data-v-a7b5672a><div class="VPMenu" data-v-a7b5672a data-v-e7ea1737><div class="items" data-v-e7ea1737><!--[--><!--[--><div class="VPMenuGroup" data-v-e7ea1737 data-v-69e747b5><!----><!--[--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/%E8%BD%AF%E4%BB%B6%E6%B5%8B%E8%AF%95/%E6%B5%8B%E8%AF%95%E5%9F%BA%E7%A1%80.html" data-v-2f2cfafc><!--[-->测试基础<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/%E8%BD%AF%E4%BB%B6%E6%B5%8B%E8%AF%95/%E5%8E%8B%E5%8A%9B%E6%B5%8B%E8%AF%95.html" data-v-2f2cfafc><!--[-->压力测试<!--]--></a></div><!--]--><!--]--></div><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--[--><div class="VPFlyout VPNavBarMenuGroup" data-v-7f418b0f data-v-a7b5672a><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-a7b5672a><span class="text" data-v-a7b5672a><!----><span data-v-a7b5672a>多线程</span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="text-icon" data-v-a7b5672a><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="menu" data-v-a7b5672a><div class="VPMenu" data-v-a7b5672a data-v-e7ea1737><div class="items" data-v-e7ea1737><!--[--><!--[--><div class="VPMenuGroup" data-v-e7ea1737 data-v-69e747b5><!----><!--[--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/%E5%B9%B6%E5%8F%91%20&amp;%20%E5%A4%9A%E7%BA%BF%E7%A8%8B/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-2f2cfafc><!--[-->基础篇<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/%E5%B9%B6%E5%8F%91%20&amp;%20%E5%A4%9A%E7%BA%BF%E7%A8%8B/%E5%B9%B6%E5%8F%91%E5%AE%8C%E5%96%84.html" data-v-2f2cfafc><!--[-->进阶篇<!--]--></a></div><!--]--><!--]--></div><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--[--><div class="VPFlyout VPNavBarMenuGroup" data-v-7f418b0f data-v-a7b5672a><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-a7b5672a><span class="text" data-v-a7b5672a><!----><span data-v-a7b5672a>开发工具</span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="text-icon" data-v-a7b5672a><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="menu" data-v-a7b5672a><div class="VPMenu" data-v-a7b5672a data-v-e7ea1737><div class="items" data-v-e7ea1737><!--[--><!--[--><div class="VPMenuGroup" data-v-e7ea1737 data-v-69e747b5><!----><!--[--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/IDEA/Chrome.html" data-v-2f2cfafc><!--[-->Chrome<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/IDEA/IDEA%E5%9F%BA%E7%A1%80.html" data-v-2f2cfafc><!--[-->IDEA基础<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/IDEA/IDEA%E6%8F%92%E4%BB%B6.html" data-v-2f2cfafc><!--[-->IDEA插件<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/IDEA/VS%20Code.html" data-v-2f2cfafc><!--[-->VS Code<!--]--></a></div><!--]--><!--]--></div><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--[--><div class="VPFlyout VPNavBarMenuGroup" data-v-7f418b0f data-v-a7b5672a><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-a7b5672a><span class="text" data-v-a7b5672a><!----><span data-v-a7b5672a>消息中间件</span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="text-icon" data-v-a7b5672a><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="menu" data-v-a7b5672a><div class="VPMenu" data-v-a7b5672a data-v-e7ea1737><div class="items" data-v-e7ea1737><!--[--><!--[--><div class="VPMenuGroup" data-v-e7ea1737 data-v-69e747b5><!----><!--[--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/%E6%B6%88%E6%81%AF%E4%B8%AD%E9%97%B4%E4%BB%B6/RabbitMQ.html" data-v-2f2cfafc><!--[-->RabbitMQ<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/%E6%B6%88%E6%81%AF%E4%B8%AD%E9%97%B4%E4%BB%B6/RocketMQ.html" data-v-2f2cfafc><!--[-->RocketMQ<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/%E6%B6%88%E6%81%AF%E4%B8%AD%E9%97%B4%E4%BB%B6/Kafka.html" data-v-2f2cfafc><!--[-->Kafka<!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-69e747b5 data-v-2f2cfafc><a class="VPLink link" href="/notebook/%E6%B6%88%E6%81%AF%E4%B8%AD%E9%97%B4%E4%BB%B6/Canal.html" data-v-2f2cfafc><!--[-->Canal<!--]--></a></div><!--]--><!--]--></div><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-0937f67c data-v-f6a63727><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="toggle dark mode" aria-checked="false" data-v-f6a63727 data-v-82b282f1 data-v-f3c41672><span class="check" data-v-f3c41672><span class="icon" data-v-f3c41672><!--[--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="sun" data-v-82b282f1><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="moon" data-v-82b282f1><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-0937f67c data-v-0394ad82 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://github.com/renshuo123/renshuo123.github.io" aria-label="github" target="_blank" rel="noopener" data-v-7bc22406 data-v-f80f8133><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>GitHub</title><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg></a><a class="VPSocialLink no-icon" href="#" aria-label="twitter" target="_blank" rel="noopener" data-v-7bc22406 data-v-f80f8133><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Twitter</title><path d="M23.953 4.57a10 10 0 01-2.825.775 4.958 4.958 0 002.163-2.723c-.951.555-2.005.959-3.127 1.184a4.92 4.92 0 00-8.384 4.482C7.69 8.095 4.067 6.13 1.64 3.162a4.822 4.822 0 00-.666 2.475c0 1.71.87 3.213 2.188 4.096a4.904 4.904 0 01-2.228-.616v.06a4.923 4.923 0 003.946 4.827 4.996 4.996 0 01-2.212.085 4.936 4.936 0 004.604 3.417 9.867 9.867 0 01-6.102 2.105c-.39 0-.779-.023-1.17-.067a13.995 13.995 0 007.557 2.209c9.053 0 13.998-7.496 13.998-13.985 0-.21 0-.42-.015-.63A9.935 9.935 0 0024 4.59z"/></svg></a><a class="VPSocialLink no-icon" href="https://github.com/" aria-label target="_blank" rel="noopener" data-v-7bc22406 data-v-f80f8133><svg t="1676028692954" class="icon" ...</path></svg></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-0937f67c data-v-40855f84 data-v-a7b5672a><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-a7b5672a><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="icon" data-v-a7b5672a><circle cx="12" cy="12" r="2"></circle><circle cx="19" cy="12" r="2"></circle><circle cx="5" cy="12" r="2"></circle></svg></button><div class="menu" data-v-a7b5672a><div class="VPMenu" data-v-a7b5672a data-v-e7ea1737><!----><!--[--><!--[--><!----><div class="group" data-v-40855f84><div class="item appearance" data-v-40855f84><p class="label" data-v-40855f84>Appearance</p><div class="appearance-action" data-v-40855f84><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="toggle dark mode" aria-checked="false" data-v-40855f84 data-v-82b282f1 data-v-f3c41672><span class="check" data-v-f3c41672><span class="icon" data-v-f3c41672><!--[--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="sun" data-v-82b282f1><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="moon" data-v-82b282f1><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg><!--]--></span></span></button></div></div></div><div class="group" data-v-40855f84><div class="item social-links" data-v-40855f84><div class="VPSocialLinks social-links-list" data-v-40855f84 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://github.com/renshuo123/renshuo123.github.io" aria-label="github" target="_blank" rel="noopener" data-v-7bc22406 data-v-f80f8133><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>GitHub</title><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg></a><a class="VPSocialLink no-icon" href="#" aria-label="twitter" target="_blank" rel="noopener" data-v-7bc22406 data-v-f80f8133><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Twitter</title><path d="M23.953 4.57a10 10 0 01-2.825.775 4.958 4.958 0 002.163-2.723c-.951.555-2.005.959-3.127 1.184a4.92 4.92 0 00-8.384 4.482C7.69 8.095 4.067 6.13 1.64 3.162a4.822 4.822 0 00-.666 2.475c0 1.71.87 3.213 2.188 4.096a4.904 4.904 0 01-2.228-.616v.06a4.923 4.923 0 003.946 4.827 4.996 4.996 0 01-2.212.085 4.936 4.936 0 004.604 3.417 9.867 9.867 0 01-6.102 2.105c-.39 0-.779-.023-1.17-.067a13.995 13.995 0 007.557 2.209c9.053 0 13.998-7.496 13.998-13.985 0-.21 0-.42-.015-.63A9.935 9.935 0 0024 4.59z"/></svg></a><a class="VPSocialLink no-icon" href="https://github.com/" aria-label target="_blank" rel="noopener" data-v-7bc22406 data-v-f80f8133><svg t="1676028692954" class="icon" ...</path></svg></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><!--[--><!--]--><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-0937f67c data-v-e5dd9c1c><span class="container" data-v-e5dd9c1c><span class="top" data-v-e5dd9c1c></span><span class="middle" data-v-e5dd9c1c></span><span class="bottom" data-v-e5dd9c1c></span></span></button></div></div></div></div><!----></header><div class="VPLocalNav reached-top" data-v-255ec12d data-v-5cfd5582><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-5cfd5582><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="menu-icon" data-v-5cfd5582><path d="M17,11H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,11,17,11z"></path><path d="M21,7H3C2.4,7,2,6.6,2,6s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,7,21,7z"></path><path d="M21,15H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,15,21,15z"></path><path d="M17,19H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,19,17,19z"></path></svg><span class="menu-text" data-v-5cfd5582>Menu</span></button><div class="VPLocalNavOutlineDropdown" style="--vp-vh:0px;" data-v-5cfd5582 data-v-18201f51><button data-v-18201f51>Return to top</button><!----></div></div><aside class="VPSidebar" data-v-255ec12d data-v-845b8fc6><div class="curtain" data-v-845b8fc6></div><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-845b8fc6><span class="visually-hidden" id="sidebar-aria-label" data-v-845b8fc6> Sidebar Navigation </span><!--[--><!--]--><!--[--><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>Java</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Java/Java%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Java基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Java/Java%E6%96%B0%E7%89%B9%E6%80%A7.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Java新特性</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Java/Java%E8%BF%9B%E9%98%B6.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Java进阶</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Java/Java%E9%9B%86%E5%90%88.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Java集合</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Java/Java%E9%AB%98%E7%BA%A7.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Java高级</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>Linux</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Linux/Linux%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Linux基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Linux/Linux%E8%BF%9B%E9%98%B6.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Linux新特性</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Linux/Shell.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Shell脚本</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Linux/%E5%AE%9E%E7%94%A8%E8%84%9A%E6%9C%AC.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>实用脚本</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Linux/%E8%BD%AF%E4%BB%B6%E9%83%A8%E7%BD%B2.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>软件部署</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>Nginx</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Nginx/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>基础篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Nginx/%E8%BF%9B%E9%98%B6%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>进阶篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Nginx/%E5%AE%9E%E6%88%98%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>实战篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Nginx/%E9%9D%A2%E8%AF%95%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>面试篇</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>SSM</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/SSM/Maven.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Maven</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/SSM/Spring.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Spring</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/SSM/SpringMVC.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>SpringMVC</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/SSM/SpringBatch.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>SpringBatch</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>SpringBoot</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/3%E3%80%81SpringBoot/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>基础篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/3%E3%80%81SpringBoot/%E5%BA%94%E7%94%A8%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>应用篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/3%E3%80%81SpringBoot/%E6%96%B0%E7%89%B9%E6%80%A7.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>新特性</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/3%E3%80%81SpringBoot/%E8%BF%90%E7%BB%B4&amp;%E5%8E%9F%E7%90%86.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>运维&原理</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>SpringCloud</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/4%E3%80%81%E5%BE%AE%E6%9C%8D%E5%8A%A1/%E8%BF%9B%E9%98%B6.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>SpringCloud</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/4%E3%80%81%E5%BE%AE%E6%9C%8D%E5%8A%A1/%E5%BF%85%E5%A4%87/Sentinel.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Sentinel</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>SpringSecurity</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/4%E3%80%81%E5%BE%AE%E6%9C%8D%E5%8A%A1/SpringSecurity/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>SpringSecurity基础篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/4%E3%80%81%E5%BE%AE%E6%9C%8D%E5%8A%A1/SpringSecurity/%E8%BF%9B%E9%98%B6%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>SpringSecurity进阶篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/4%E3%80%81%E5%BE%AE%E6%9C%8D%E5%8A%A1/SpringSecurity/%E9%AB%98%E7%BA%A7%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>SpringSecurity高级篇</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>Mybatis & MybatisPlus</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Mybatis&amp;MybatisPlus/Mybatis.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Mybatis</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Mybatis&amp;MybatisPlus/MybatisPlus.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>MybatisPlus</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/Mybatis&amp;MybatisPlus/JPA.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>JPA</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible has-active" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>Git & ChatGPT</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/5%E3%80%81%E8%BF%90%E7%BB%B4/Git.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Git</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/5%E3%80%81%E8%BF%90%E7%BB%B4/Github.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Github</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/5%E3%80%81%E8%BF%90%E7%BB%B4/ChatGPT.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>ChatGPT</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/5%E3%80%81%E8%BF%90%E7%BB%B4/Jenkins.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Jenkins</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/5%E3%80%81%E8%BF%90%E7%BB%B4/Netty.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Netty</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>数据库</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>MySQL</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/MySQL/MySQL%E6%A0%B8%E5%BF%83/%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>MySQL基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/MySQL/MySQL%E6%A0%B8%E5%BF%83/%E8%BF%9B%E9%98%B6.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>MySQL进阶</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/MySQL/MySQL%E6%A0%B8%E5%BF%83/%E4%BC%98%E5%8C%96.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>MySQL优化</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/MySQL/MySQL%E6%A0%B8%E5%BF%83/%E8%AE%BE%E8%AE%A1.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>MySQL设计</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/MySQL/MySQL%E6%A0%B8%E5%BF%83/%E8%BF%90%E7%BB%B4.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>MySQL运维</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/MySQL/%E5%88%86%E5%BA%93%E5%88%86%E8%A1%A8.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>分库分表</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>Redis</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/Redis/Redis%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Redis基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/Redis/Redis%E4%BC%98%E5%8C%96.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Redis优化</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/Redis/Redis%E5%8E%9F%E7%90%86.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Redis原理</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/Redis/Redis%E9%AB%98%E7%BA%A7.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Redis高级</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/Redis/Redis%E5%AE%9E%E6%88%98.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Redis实战</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/Redis/%E6%9C%AC%E5%9C%B0%E7%BC%93%E5%AD%98.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>本地缓存</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>MongoDB</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/MongoDB/%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>MongoDB基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/MongoDB/%E6%95%B4%E5%90%88.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>MongoDB进阶</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>ElasticSearch</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/ElasticSearch/1%E3%80%81ES%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>ES基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/ElasticSearch/3%E3%80%81ES%E9%AB%98%E7%BA%A7.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>ES高级</p><!--]--></a><!----></div><!----></div><!--]--></div></section><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/influxdb.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>InfluxDB</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/2%E3%80%81%E6%95%B0%E6%8D%AE%E5%BA%93/Neo4j.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Neo4j</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>高并发 & 秒杀 & 分布式</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E4%B8%89%E9%AB%98/%E5%88%86%E5%B8%83%E5%BC%8F.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>分布式理论</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/4%E3%80%81%E5%BE%AE%E6%9C%8D%E5%8A%A1/%E5%BF%85%E5%A4%87/%E5%88%86%E5%B8%83%E5%BC%8F%E9%94%81.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>分布式锁</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E4%B8%89%E9%AB%98/%E7%A7%92%E6%9D%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>秒杀</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E4%B8%89%E9%AB%98/%E9%AB%98%E5%8F%AF%E7%94%A8.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>高可用</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E4%B8%89%E9%AB%98/%E9%AB%98%E5%B9%B6%E5%8F%91.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>高并发</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>云原生</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E4%BA%91%E5%8E%9F%E7%94%9F/Docker.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Docker</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E4%BA%91%E5%8E%9F%E7%94%9F/K8S.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>K8S</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>可视化 & 监控</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E5%8F%AF%E8%A7%86%E5%8C%96%20&amp;%20%E7%9B%91%E6%8E%A7/%E7%9B%91%E6%8E%A7%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>监控基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E5%8F%AF%E8%A7%86%E5%8C%96%20&amp;%20%E7%9B%91%E6%8E%A7/%E7%9B%91%E6%8E%A7%E8%BF%9B%E9%98%B6.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>监控进阶</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E5%8F%AF%E8%A7%86%E5%8C%96%20&amp;%20%E7%9B%91%E6%8E%A7/%E5%8F%AF%E8%A7%86%E5%8C%96%E5%A4%A7%E5%B1%8F.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>可视化大屏</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E5%8F%AF%E8%A7%86%E5%8C%96%20&amp;%20%E7%9B%91%E6%8E%A7/Zabbix.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Zabbix</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>学前端</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>HTML+CSS</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/1%E3%80%81HTML+CSS/HTML%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>HTML基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/1%E3%80%81HTML+CSS/CSS%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>CSS基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/1%E3%80%81HTML+CSS/%E7%BD%91%E9%A1%B5%E8%BF%9B%E9%98%B6.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>网页进阶</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>JS+TS</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/2%E3%80%81JS+TS/JS%20%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>JS基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/2%E3%80%81JS+TS/JS%20%E8%BF%9B%E9%98%B6.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>JS进阶</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/2%E3%80%81JS+TS/ES6%20%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>ES6基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/2%E3%80%81JS+TS/ES6%20%E8%BF%9B%E9%98%B6.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>ES6进阶</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/2%E3%80%81JS+TS/TypeScript.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>TS基础</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>NodeJS</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/4%E3%80%81Node/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Node基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/4%E3%80%81Node/%E8%BF%9B%E9%98%B6%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Node进阶</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/4%E3%80%81Node/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>项目实战</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>Vue</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/3%E3%80%81Vue/Vue3/Vue3%E8%BF%9B%E9%98%B6.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Vue3进阶</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/3%E3%80%81Vue/Vue3/Vue3%E9%AB%98%E7%BA%A7.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Vue3高级</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/3%E3%80%81Vue/Vue3/Vue3%E6%96%B0%E8%AF%AD%E6%B3%95.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>Vue3新语法</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/3%E3%80%81Vue/Vue2/Vue2%E9%A1%B9%E7%9B%AE.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>项目实战</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>小程序</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/5%E3%80%81%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>小程序基础</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/5%E3%80%81%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%B0%8F%E7%A8%8B%E5%BA%8F%E4%BC%98%E5%8C%96.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>小程序优化</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/5%E3%80%81%E5%B0%8F%E7%A8%8B%E5%BA%8F/uniapp.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>uniapp</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/1%E3%80%81%E5%AD%A6%E5%89%8D%E7%AB%AF/5%E3%80%81%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E5%B0%8F%E7%A8%8B%E5%BA%8F%E9%A1%B9%E7%9B%AE.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>项目实战</p><!--]--></a><!----></div><!----></div><!--]--></div></section><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>计算机基础</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9F%BA%E7%A1%80/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>数据结构</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9F%BA%E7%A1%80/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9F%BA%E7%A1%80/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>操作系统</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9F%BA%E7%A1%80/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>设计模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9F%BA%E7%A1%80/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/%E7%BD%91%E7%BB%9C%E5%9F%BA%E7%A1%80.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>计算机网络</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9F%BA%E7%A1%80/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/UML.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>UML</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9F%BA%E7%A1%80/%E7%AE%97%E6%B3%95/LeetCode.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>LeetCode</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0 collapsible collapsed" data-v-845b8fc6 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h2 class="text" data-v-9b797284>项目实战</h2><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>云尚办公</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E4%BA%91%E5%B0%9A%E5%8A%9E%E5%85%AC/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>基础篇</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>小兔鲜</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E5%B0%8F%E5%85%94%E9%B2%9C/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>基础篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E5%B0%8F%E5%85%94%E9%B2%9C/%E8%BF%9B%E9%98%B6%E7%AF%871.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>进阶篇1</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E5%B0%8F%E5%85%94%E9%B2%9C/%E8%BF%9B%E9%98%B6%E7%AF%872.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>进阶篇2</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>地图</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E7%99%BE%E5%BA%A6%E5%9C%B0%E5%9B%BE/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>基础篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E7%99%BE%E5%BA%A6%E5%9C%B0%E5%9B%BE/%E8%BF%9B%E9%98%B6%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>进阶篇</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>苍穹外卖</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E8%8B%8D%E7%A9%B9%E5%A4%96%E5%8D%96/%E8%BF%9B%E9%98%B6%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>进阶篇</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-9b797284 data-v-9b797284><div class="item" role="button" tabindex="0" data-v-9b797284><div class="indicator" data-v-9b797284></div><h3 class="text" data-v-9b797284>黑马头条</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-9b797284><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="caret-icon" data-v-9b797284><path d="M9,19c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l5.3-5.3L8.3,6.7c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l6,6c0.4,0.4,0.4,1,0,1.4l-6,6C9.5,18.9,9.3,19,9,19z"></path></svg></div></div><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E9%BB%91%E9%A9%AC%E5%A4%B4%E6%9D%A1/%E5%9F%BA%E7%A1%80%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>基础篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E9%BB%91%E9%A9%AC%E5%A4%B4%E6%9D%A1/%E8%BF%9B%E9%98%B6%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>进阶篇</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E9%BB%91%E9%A9%AC%E5%A4%B4%E6%9D%A1/%E8%BF%9B%E9%98%B6%E7%AF%872.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>进阶篇2</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E9%BB%91%E9%A9%AC%E5%A4%B4%E6%9D%A1/%E9%AB%98%E7%BA%A7%E7%AF%87.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>高级篇</p><!--]--></a><!----></div><!----></div><!--]--></div></section><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E6%94%AF%E4%BB%98.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>支付</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98/%E9%A1%B9%E7%9B%AE%E6%8E%A8%E8%8D%90.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>项目推荐</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-845b8fc6><section class="VPSidebarItem level-0" data-v-845b8fc6 data-v-9b797284><!----><div class="items" data-v-9b797284><!--[--><div class="VPSidebarItem level-1 is-link" data-v-9b797284 data-v-9b797284><div class="item" data-v-9b797284><div class="indicator" data-v-9b797284></div><a class="VPLink link link" href="/notebook/team.html" data-v-9b797284><!--[--><p class="text" data-v-9b797284>团队成员</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><!--]--><!--[--><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-255ec12d data-v-669faec9><div class="VPDoc has-sidebar has-aside" data-v-669faec9 data-v-6b87e69f><!--[--><!--]--><div class="container" data-v-6b87e69f><div class="aside" data-v-6b87e69f><div class="aside-curtain" data-v-6b87e69f></div><div class="aside-container" data-v-6b87e69f><div class="aside-content" data-v-6b87e69f><div class="VPDocAside" data-v-6b87e69f data-v-3f215769><!--[--><!--]--><!--[--><!--]--><div class="VPDocAsideOutline" data-v-3f215769 data-v-ff0f39c8><div class="content" data-v-ff0f39c8><div class="outline-marker" data-v-ff0f39c8></div><div class="outline-title" data-v-ff0f39c8>On this page</div><nav aria-labelledby="doc-outline-aria-label" data-v-ff0f39c8><span class="visually-hidden" id="doc-outline-aria-label" data-v-ff0f39c8> Table of Contents for current page </span><ul class="root" data-v-ff0f39c8 data-v-d0ee3533><!--[--><!--]--></ul></nav></div></div><!--[--><!--]--><div class="spacer" data-v-3f215769></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-6b87e69f><div class="content-container" data-v-6b87e69f><!--[--><!--]--><!----><main class="main" data-v-6b87e69f><div style="position:relative;" class="vp-doc _notebook_5%E3%80%81%E8%BF%90%E7%BB%B4_Git" data-v-6b87e69f><div><h1 id="基本概述" tabindex="-1">基本概述 <a class="header-anchor" href="#基本概述" aria-label="Permalink to &quot;基本概述&quot;">​</a></h1><p><a href="https://mp.weixin.qq.com/s?__biz=MzU2MTIyNDUwMA==&amp;mid=2247501590&amp;idx=1&amp;sn=4c1b800cd839450e84894aee6bf6f825&amp;chksm=fc7e894dcb09005b45e81c89d5953c4ac50aefcee7f677eac53f627d8ee4a314317de37968fd&amp;mpshare=1&amp;scene=23&amp;srcid=1223QEty73SsVUNBgB1vvCtq&amp;sharer_sharetime=1671760896332&amp;sharer_shareid=29b8a04db1dbd975e3bf4e9f47e7ac67#rd" target="_blank" rel="noreferrer">学习 Git，看这一篇就够了！</a></p><p><a href="https://mp.weixin.qq.com/s?__biz=MzU5NTgzMDYyMA==&amp;mid=2247503985&amp;idx=2&amp;sn=a8421c6e928f49f9c66ed24af4ef9963&amp;chksm=fe696242c91eeb54ddc78a848392cf35dffbad007ac776edf475f533b4eb0e65e8f8cd638302&amp;mpshare=1&amp;scene=23&amp;srcid=0406iIU4eEorv55820LkWDJS&amp;sharer_sharetime=1680794588354&amp;sharer_shareid=29b8a04db1dbd975e3bf4e9f47e7ac67#rd" target="_blank" rel="noreferrer">我看谁还不懂 Git ！(万字干货)</a></p><p><a href="https://mp.weixin.qq.com/s?__biz=Mzk0NzI3ODMyMA==&amp;mid=2247516787&amp;idx=2&amp;sn=52d644b14c372fdac0b15c4813c5efa1&amp;chksm=c37b9aecf40c13fae8c00cb2cc0c4d12f0c125621a736773aa6a66cd542374ea3606d426c2d3&amp;mpshare=1&amp;scene=23&amp;srcid=0411LWwPJ3K52ne2tqJObUxN&amp;sharer_sharetime=1681142878024&amp;sharer_shareid=29b8a04db1dbd975e3bf4e9f47e7ac67#rd" target="_blank" rel="noreferrer">给自己点时间再记记这 200 条 Git 命令</a></p><h2 id="基本概念" tabindex="-1">基本概念 <a class="header-anchor" href="#基本概念" aria-label="Permalink to &quot;基本概念&quot;">​</a></h2><p>Git是当前最先进、最主流的<strong>分布式</strong>版本控制系统，免费、开源！核心能力就是版本控制。再具体一点，就是面向代码文件的版本控制，代码的任何修改历史都会被记录管理起来，意味着可以恢复到到以前的任意时刻状态。支持跨区域多人协作编辑，是团队项目开发的必备基础，所以Git也就成了程序员的必备技能。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092045117.png" alt="image-20230409204521954" style="zoom:80%;"><ul><li>开源免费，使用广泛。</li><li>强大的文档（代码）的历史版本管理，直接记录完整快照（完整内容，而非差异），支持回滚、对比。</li><li>分布式多人协作的的代码协同开发，几乎所有操作都是本地执行的，支持代码合并、代码同步。</li><li>简单易用的分支管理，支持高效的创建分支、合并分支。</li></ul><h3 id="版本控制系统" tabindex="-1">版本控制系统 <a class="header-anchor" href="#版本控制系统" aria-label="Permalink to &quot;版本控制系统&quot;">​</a></h3><blockquote><p>版本控制是指对软件开发过程中各种程序代码、配置文件及说明文档等文件变更的管理，是软件配置管理的核心思想之一。版本控制技术是团队协作开发的桥梁，助力于多人协作同步进行大型项目开发。软件版本控制系统的核心任务就是查阅项目历史操作记录、实现协同开发。</p></blockquote><p>常见版本控制主要有两种：<strong>集中式版本控制</strong>和<strong>分布式版本控制</strong>。</p><h4 id="集中式版本控制系统" tabindex="-1">集中式版本控制系统 <a class="header-anchor" href="#集中式版本控制系统" aria-label="Permalink to &quot;集中式版本控制系统&quot;">​</a></h4><blockquote><p>集中式版本控制系统，版本库是集中存放在中央服务器的。**工作时，每个人都要先从中央服务器获取最新的版本。完成之后，再把自己添加/修改的内容提交到中央服务器。所有文件和历史数据都存储在中央服务器上。**SVN 是最流行的集中式版本控制系统之一。</p></blockquote><blockquote><p>集中式版本控制系统的缺点就是必须联网才能使用，如果使用局域网还好，速度会比较快。而如果是使用互联网，网速慢的话，就可能需要等待很长时间。除此之外，如果中央服务器出现故障，那么版本控制将不可用。如果中心数据库损坏，若数据未备份，数据就会丢失。</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.1.30/202212251226826.png" alt="image-20221225122613742" style="zoom:50%;"><h4 id="分布式版本控制系统" tabindex="-1">分布式版本控制系统 <a class="header-anchor" href="#分布式版本控制系统" aria-label="Permalink to &quot;分布式版本控制系统&quot;">​</a></h4><blockquote><p>分布式版本控制系统，每台终端都可以保存版本库，版本库可以不同，可以对每个版本库进行修改，修改完成后可以集中进行更新。虽然它没有中心服务器，但可以有一个备份服务器，它的功能有点类似于 SVN 的中央服务器，但它的作用仅是方便交换修改，而不像 SVN 那样还要负责源代码的管理。Git 是最流行的分布式版本控制系统之一。</p></blockquote><blockquote><p>和集中式版本控制系统相比，分布式版本控制系统的安全性要高很多，因为每个人电脑里都有完整的版本库，某一个人的电脑损坏不会影响到协作的其他人。</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.1.30/202212251226823.png" alt="image-20221225122639711" style="zoom:67%;"><h4 id="svn-vs-git" tabindex="-1">SVN vs Git <a class="header-anchor" href="#svn-vs-git" aria-label="Permalink to &quot;SVN vs Git&quot;">​</a></h4><blockquote><p><strong>提交速度更快：</strong> 因为在 SVN 中需要更频繁地提交到中央存储库，所以网络流量会减慢每个人的速度。而使用 Git，主要在本地存储库上工作，只需每隔一段时间才提交到中央存储库。</p></blockquote><blockquote><p><strong>没有单点故障：</strong> 使用 SVN，如果中央存储库出现故障，则在修复存储库之前，其他开发人员无法提交他们的代码。使用 Git，每个开发人员都有自己的存储库，因此中央存储库是否损坏并不重要。开发人员可以继续在本地提交代码，直到中央存储库被修复，然后就可以推送他们的更改；</p></blockquote><blockquote><p><strong>可以离线使用：</strong> 与 SVN 不同，Git 可以离线工作，即使网络失去连接，也可以继续工作而不会丢失功能。</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304070911276.png" alt="image-20230407091150136" style="zoom:80%;"><h3 id="版本控制" tabindex="-1">版本控制 <a class="header-anchor" href="#版本控制" aria-label="Permalink to &quot;版本控制&quot;">​</a></h3><blockquote><p>一般情况下，一份文件，无论是DOC办公文档，还是编程源码文件，我们都会对文件进行大量的修改和变更。但是我们无法保证每一次的修改和变更都是正确并有效的，往往有的时候需要追溯历史操作，而版本控制（Revision control）是一种在开发的过程中用于管理我们对文件、目录或工程等内容的修改历史，方便查看更改历史记录，备份以便恢复以前的版本的软件工程技术。</p></blockquote><blockquote><p>没有进行版本控制或者版本控制本身缺乏正确的流程管理，在软件开发过程中将会引入很多问题，如软件代码的一致性、软件内容的冗余、软件过程的事物性、软件开发过程中的并发性、软件源代码的安全性，以及软件的整合等问题。</p></blockquote><h3 id="分布式系统" tabindex="-1">分布式系统 <a class="header-anchor" href="#分布式系统" aria-label="Permalink to &quot;分布式系统&quot;">​</a></h3><blockquote><p>在Git中，每个版本库都是一样重要得。所以就不存在像集中式版本控制软件中以谁为主得问题。任何一个库都可以当成主库。这种方式可以更大限度地保证项目资源得安全。</p></blockquote><h3 id="概念汇总" tabindex="-1">概念汇总 <a class="header-anchor" href="#概念汇总" aria-label="Permalink to &quot;概念汇总&quot;">​</a></h3><table><thead><tr><th style="text-align:left;"><strong>概念名称</strong></th><th style="text-align:left;"><strong>描述</strong></th></tr></thead><tbody><tr><td style="text-align:left;"><strong>工作区</strong>（Workspace）</td><td style="text-align:left;">就是在电脑里能看到的代码库目录，是我们搬砖的地方，新增、修改的文件会提交到暂存区</td></tr><tr><td style="text-align:left;"><strong>暂存区</strong>（stage 或 index）</td><td style="text-align:left;">用于临时存放文件的修改，实际上上它只是一个文件（<code>.git/index</code>），保存待提交的文件列表信息。</td></tr><tr><td style="text-align:left;"><strong>版本库/仓库</strong>（Repository）</td><td style="text-align:left;">Git的管理仓库，管理版本的数据库，记录文件/目录状态的地方，所有内容的修改记录（版本）都在这里。</td></tr><tr><td style="text-align:left;"><strong>服务端/远程仓库</strong>（origin 或 remote）</td><td style="text-align:left;">服务端的版本库，专用的Git服务器，为多人共享提供服务，承担中心服务器的角色。本地版本库通过push指令把代码推送到服务端版本库。</td></tr><tr><td style="text-align:left;"><strong>本地仓库</strong></td><td style="text-align:left;">用户机器上直接使用的的的版本库</td></tr><tr><td style="text-align:left;"><strong>分支</strong>（Branch）</td><td style="text-align:left;">分支是从主线分离出去的“副本”，可以独立操作而互不干扰，仓库初始化就有一个默认主分支<code>master</code>。</td></tr><tr><td style="text-align:left;"><strong>头</strong>（HEAD）</td><td style="text-align:left;">HEAD类似一个“指针”，指向当前活动 <strong>分支</strong> 的 <strong>最新版本</strong>。</td></tr><tr><td style="text-align:left;"><strong>提交</strong>（Commit）</td><td style="text-align:left;">把暂存区的所有变更的内容提交到当前仓库的活动分支。</td></tr><tr><td style="text-align:left;"><strong>推送</strong>（Push）</td><td style="text-align:left;">将本地仓库的版本推送到服务端（远程）仓库，与他人共享。</td></tr><tr><td style="text-align:left;"><strong>拉取</strong>（Pull）</td><td style="text-align:left;">从服务端（远程）仓库获取更新到本地仓库，获取他人共享的更新。</td></tr><tr><td style="text-align:left;"><strong>获取</strong>（Fetch）</td><td style="text-align:left;">从服务端（远程）仓库更新，作用同拉取（Pull），区别是不会自动合并。</td></tr><tr><td style="text-align:left;"><strong>冲突</strong>（Conflict）</td><td style="text-align:left;">多人对同一文件的工作副本进行更改，并将这些更改合并到仓库时就会面临冲突，需要人工合并处理。</td></tr><tr><td style="text-align:left;"><strong>合并</strong>（Merge）</td><td style="text-align:left;">对有冲突的文件进行合并操作，Git会自动合并变更内容，无法自动处理的冲突内容会提示人工处理。</td></tr><tr><td style="text-align:left;"><strong>标签</strong>（Tags）</td><td style="text-align:left;">标签指的是某个分支某个特定时间点的状态，可以理解为提交记录的别名，常用来标记版本。</td></tr><tr><td style="text-align:left;"><strong>master</strong>（或main）</td><td style="text-align:left;">仓库的“<code>master</code>”分支，默认的主分支，初始化仓库就有了。Github上创建的仓库默认名字为“<code>main</code>”</td></tr><tr><td style="text-align:left;"><strong>origin/master</strong></td><td style="text-align:left;">表示远程仓库（<code>origin</code>）的“<code>master</code>”分支</td></tr><tr><td style="text-align:left;"><strong>origin/HEAD</strong></td><td style="text-align:left;">表示远程仓库（<code>origin</code>）的最新提交的位置，一般情况等于“<code>origin/master</code>”</td></tr></tbody></table><h3 id="工作区、暂存区、仓库" tabindex="-1">工作区、暂存区、仓库 <a class="header-anchor" href="#工作区、暂存区、仓库" aria-label="Permalink to &quot;工作区、暂存区、仓库&quot;">​</a></h3><blockquote><p>Git软件为了更方便地对文件进行版本控制，根据功能得不同划分了三个区域</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092049739.png" alt="image-20230409204921564" style="zoom:80%;"><blockquote><p><strong>工作区</strong>（Workspace）就是在电脑里能看到的代码库目录，是我们搬砖的地方，新增、修改的文件会提交到暂存区。在这里新增文件、修改文件内容，或删除文件。</p></blockquote><blockquote><p><strong>暂存区</strong>（stage或index） 用于临时存放文件的修改，实际上上它只是一个文件（.git/index），保存待提交的文件列表信息。用<code>git add</code> 命令将工作区的修改保存到暂存区。</p></blockquote><blockquote><p><strong>版本库/仓库</strong>（Repository /rɪˈpɑːzətɔːri/ 仓库）Git的管理仓库，管理版本的数据库，记录文件/目录状态的地方，所有内容的修改记录（版本）都在这里。就是工作区目录下的隐藏文件夹<code>.git</code>，包含暂存区、分支、历史记录等信息。用<code>git commit</code> 命令将暂存区的内容正式提交到版本库。<code>master</code> 为仓库的默认分支<code>master</code>，<strong>HEAD</strong>是一个“指针”指向当前分支的最新提交，默认指向最新的<code>master</code>。</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092050980.png" alt="image-20230409205020822" style="zoom:80%;"><p>如上图，为对应本地仓库目录的结构关系。</p><ul><li><code>KWebNote</code>为项目目录，也就是Git工作区。</li><li>项目根目录下隐藏的<code>.git</code>目录就是Git仓库目录了，存放了所有Git管理的信息。</li><li><code>.git/config</code>为该仓库的配置文件，可通过指令修改或直接修改。</li><li><code>index</code>文件就是存放的暂存区内容。</li></ul><h2 id="基本流程" tabindex="-1">基本流程 <a class="header-anchor" href="#基本流程" aria-label="Permalink to &quot;基本流程&quot;">​</a></h2><p>Git的工作流程核心就下面几个步骤，掌握了就可以开始写Bug了。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.6.30/202207231802658.png" alt="image-20220723180255581" style="zoom:80%;"><p>0、<strong>准备仓库</strong>：创建或从服务端克隆一个仓库。</p><p>1、<strong>搬砖</strong>：在工作目录中添加、修改代码。</p><p>2、<strong>暂存</strong>（git add）：将需要进行版本管理的文件放入暂存区域。</p><p>3、<strong>提交</strong>（git commit）：将暂存区域的文件提交到Git仓库。</p><p>4、<strong>推送</strong>（git push）：将本地仓库推送到远程仓库，同步版本库。</p><p>5、<strong>获取更新</strong>（fetch/pull）：从服务端更新到本地，获取他人推送的更新，与他人协作、共享。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092052924.png" alt="image-20230409205205755" style="zoom:80%;"><ul><li><code>git commit -a</code>指令省略了<code>add</code>到暂存区的步骤，直接提交工作区的修改内容到版本库，不包括新增的文件</li><li><code>git fetch</code>、<code>git pull</code> 都是从远程服务端获取最新记录，区别是<code>git pull</code>多个步骤，自动合并更新工作区</li><li><code>git checkout .</code>、<code>git checkout [file]</code> 会清除工作区中未添加到暂存区的修改，用暂存区内容替换工作区。</li><li><code>git checkout HEAD .</code>、<code>git checkout HEAD [file]</code> 会清除工作区、暂存区的修改，用HEAD指向的当前分支最新版本替换暂存区、工作区。</li><li><code>git diff</code> 用来对比不同部分之间的区别，如暂存区、工作区，最新版本与未提交内容，不同版本之间等。</li><li><code>git reset</code>是专门用来撤销修改、回退版本的指令，替代上面<code>checkout</code>的撤销功能。</li></ul><h2 id="文件状态" tabindex="-1">文件状态 <a class="header-anchor" href="#文件状态" aria-label="Permalink to &quot;文件状态&quot;">​</a></h2><p>Git在执行提交的时候，不是直接将工作区的修改保存到仓库，而是将暂存区域的修改保存到仓库。要提交文件，首先需要把文件加入到暂存区域中。因此，Git管理的文件有三（+2）种状态：</p><ul><li>未跟踪（untracked）：新添加的文件，或被移除跟踪的文件，未建立跟踪，通过<code>git add</code>添加暂存并建立跟踪。</li><li>未修改：从仓库签出的文件默认状态，修改后就是“已修改”状态了。</li><li><strong>已修改</strong>（modified）：文件被修改后的状态。</li><li><strong>已暂存</strong>（staged）：修改、新增的文件添加到暂存区后的状态。</li><li><strong>已提交</strong>(committed)：从暂存区提交到版本库。</li></ul><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092051483.png" alt="image-20230409205124298" style="zoom:80%;"><h2 id="使用场景" tabindex="-1">使用场景 <a class="header-anchor" href="#使用场景" aria-label="Permalink to &quot;使用场景&quot;">​</a></h2><h3 id="场景一-备份" tabindex="-1">场景一：备份 <a class="header-anchor" href="#场景一-备份" aria-label="Permalink to &quot;场景一：备份&quot;">​</a></h3><p>小明负责的模块就要完成了，就在即将Release之前的一瞬间，电脑突然蓝屏，硬盘光荣牺牲！几个月 来的努力付之东流</p><h3 id="场景二-代码还原" tabindex="-1">场景二：代码还原 <a class="header-anchor" href="#场景二-代码还原" aria-label="Permalink to &quot;场景二：代码还原&quot;">​</a></h3><p>这个项目中需要一个很复杂的功能，老王摸索了一个星期终于有眉目了，可是这被改得面目全非的 代码已经回不到从前了。什么地方能买到哆啦A梦的时光机啊？</p><h3 id="场景三-协同开发" tabindex="-1">场景三：协同开发 <a class="header-anchor" href="#场景三-协同开发" aria-label="Permalink to &quot;场景三：协同开发&quot;">​</a></h3><p>小刚和小强先后从文件服务器上下载了同一个文件：Analysis.java。</p><p>小刚在Analysis.java文件中的第30行声明了一个方法，叫count()，先保存到了文件服务器上；</p><p>小强在Analysis.java文件中的第50行声明了一个方法，叫sum()，也随后保存到了文件服务器上，于是，count()方法就只存在于小刚的记忆中了</p><h3 id="场景四-追溯问题代码" tabindex="-1">场景四：追溯问题代码 <a class="header-anchor" href="#场景四-追溯问题代码" aria-label="Permalink to &quot;场景四：追溯问题代码&quot;">​</a></h3><p>老王是另一位项目经理，每次因为项目进度挨骂之后，他都不知道该扣哪个程序员的工资！就拿这次来说吧，有个Bug调试了30多个小时才知道是因为相关属性没有在应用初始化时赋值！可是二胖、王东、刘流和正经牛都不承认是自己干的！</p><h2 id="学习资源" tabindex="-1">学习资源 <a class="header-anchor" href="#学习资源" aria-label="Permalink to &quot;学习资源&quot;">​</a></h2><h3 id="git-help" tabindex="-1">git help <a class="header-anchor" href="#git-help" aria-label="Permalink to &quot;git help&quot;">​</a></h3><p>其实我个人使用最多的是<code>git help</code>,真心方便又好用啊！比如 <code>git help pull</code>:</p><p>先介绍了有哪些参数，然后 description 详细解释了它的工作原理，下面还有图解，有木有太香！！</p><p>不过这种方式更像是 <code>cheatsheet</code>，当你已经知道了这个命令、只是忘了它的用法的时候去查。</p><p>如果你想系统的学习，那么下面 👇 的更适合你。</p><h3 id="pro-git" tabindex="-1">Pro Git <a class="header-anchor" href="#pro-git" aria-label="Permalink to &quot;Pro Git&quot;">​</a></h3><p>这本书是强烈推荐了！！Pro Git 这本书不仅讲了 Git 的基础用法、高级用法，以及最后还深入讲解了 Git 的原理，非常细致全面。书的电子版也能在网站上直接下载。</p><p>英文版：<code>https://git-scm.com/book/en/v2</code></p><p>中文版：<code>https://git-scm.com/book/zh/v2</code></p><h3 id="git-game" tabindex="-1">Git Game <a class="header-anchor" href="#git-game" aria-label="Permalink to &quot;Git Game&quot;">​</a></h3><p>Practice makes perfect!</p><p>推荐一个宝藏资源：玩游戏来练 Git</p><p>项目：<code>https://github.com/pcottle/learnGitBranching</code></p><p>网址：<code>https://learngitbranching.js.org/</code></p><p>我熟悉很多工具都是通过小游戏来练习的，比如 vim 的操作，还是蛮推荐这种方式的。就不剧透啦，大家自己去探索吧</p><h2 id="注意事项" tabindex="-1">注意事项 <a class="header-anchor" href="#注意事项" aria-label="Permalink to &quot;注意事项&quot;">​</a></h2><h3 id="ssh公钥错误" tabindex="-1">SSH公钥错误 <a class="header-anchor" href="#ssh公钥错误" aria-label="Permalink to &quot;SSH公钥错误&quot;">​</a></h3><p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304062024712.jpg" alt="img"></p><p>一般出现如上错误，就是Git远程仓库的SSH免密公钥和推送用户提供的公钥不一致导致的。</p><h3 id="idea集成gitee失败" tabindex="-1">IDEA集成Gitee失败 <a class="header-anchor" href="#idea集成gitee失败" aria-label="Permalink to &quot;IDEA集成Gitee失败&quot;">​</a></h3><p>如果IDEA集成Gitee时，向远程仓库push代码失败，且没有弹出账号窗口，可以尝试修改IDEA得相关配置。</p><h3 id="解决gitbash乱码问题-可选" tabindex="-1">解决GitBash乱码问题(可选) <a class="header-anchor" href="#解决gitbash乱码问题-可选" aria-label="Permalink to &quot;解决GitBash乱码问题(可选)&quot;">​</a></h3><p>打开GitBash执行下面命令</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git config </span><span style="color:#89DDFF;">--</span><span style="color:#A6ACCD;">global core</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">quotepath false</span></span></code></pre></div><p>vi ${git_home}/etc/bash.bashrc 文件最后加入下面两行</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">export LANG</span><span style="color:#89DDFF;">=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">zh_CN.UTF-8</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">export LC_ALL</span><span style="color:#89DDFF;">=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">zh_CN.UTF-8</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><h3 id="使用铁令⭐" tabindex="-1">使用铁令⭐ <a class="header-anchor" href="#使用铁令⭐" aria-label="Permalink to &quot;使用铁令⭐&quot;">​</a></h3><blockquote><p><strong>切换分支前先提交本地的修改</strong></p><p><strong>代码及时提交，提交过了就不会丢</strong></p><p><strong>遇到任何问题都不要删除文件目录</strong></p></blockquote><h1 id="安装和配置" tabindex="-1">安装和配置 <a class="header-anchor" href="#安装和配置" aria-label="Permalink to &quot;安装和配置&quot;">​</a></h1><blockquote><p>最早Git是在Linux上开发的，很长一段时间内，Git也只能在Linux和Unix系统上跑。不过，有人把它移植到了Windows上。现在，Git可以在Linux、Unix、Mac和Windows这几大平台上正常运行了。由于开发机大多数情况都是windows，此处我们下载Windows系统的2.40.0版本软件</p></blockquote><h2 id="下载与安装" tabindex="-1">下载与安装 <a class="header-anchor" href="#下载与安装" aria-label="Permalink to &quot;下载与安装&quot;">​</a></h2><p>软件官网地址为：<a href="https://git-scm.com/" target="_blank" rel="noreferrer">https://git-scm.com/</a></p><p>软件下载地址为：<a href="https://github.com/git-for-windows/git/releases/download/v2.40.0.windows.1/Git-2.40.0-64-bit.exe" target="_blank" rel="noreferrer">Git-2.40.0-64-bit.exe</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img/image-20210930162941925.png" alt="image-20210930162941925" style="zoom:67%;"><p>下载完成后可以得到如下安装文件：</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304070925385.png" alt="image-20230407092502301" style="zoom:80%;"><blockquote><p>双击下载的安装文件来安装Git。安装完成后在电脑桌面（也可以是其他目录）点击右键，如果能够看,到如下两个菜单则说明Git安装成功。</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img/image-20210930163036923.png" alt="image-20210930163036923" style="zoom:67%;"><blockquote><ul><li><p>Git GUI：Git提供的图形界面工具</p></li><li><p>Git Bash：Git提供的命令行工具</p></li></ul></blockquote><h2 id="验证安装" tabindex="-1">验证安装 <a class="header-anchor" href="#验证安装" aria-label="Permalink to &quot;验证安装&quot;">​</a></h2><p>此处仅仅是为了验证Git软件安装的效果，所以选择Git Bash Here菜单, 选择后，Windows系统弹出Git软件的命令行黑窗口，窗口弹出后，可以输入Git软件的操作指令。此时我们使用键盘输入操作指令：git -v或 git --version，查看当前Git软件的安装版本。输入指令回车后，如果黑窗口中打印出咱们安装的软件版本2.40.0，Git软件安装成功了。</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--version</span></span></code></pre></div><p>当安装Git后首先要做的事情是设置用户名称和email地址。这是非常重要的，因为每次Git提交都会使用该用户信息</p><h2 id="配置文件" tabindex="-1">配置文件 <a class="header-anchor" href="#配置文件" aria-label="Permalink to &quot;配置文件&quot;">​</a></h2><p>Git有三个主要的配置文件：三个配置文件的优先级是<strong>① &lt; ② &lt; ③</strong></p><p><strong>① 系统全局配置</strong>(--system)：包含了适用于系统所有用户和所有仓库（项目）的配置信息，存放在Git安装目录下<code>C:\Program Files\Git\etc\gitconfig</code>。</p><p><strong>② 用户全局配置</strong>(--system)：当前系统用户的全局配置，存放用户目录：<code>C:\Users\[系统用户名]\.gitconfig</code></p><p><strong>③ 仓库/项目配置</strong>(--local)：仓库（项目）的特定配置，存放在项目目录下<code>.git/config</code></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092056958.png" alt="image-20230409205605772" style="zoom:80%;"><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;">#查看git配置</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--list</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-l</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">#查看系统配置</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--system</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--list</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">#查看当前用户（global）全局配置</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--list</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--global</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">#查看当前仓库配置信息</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--local</span><span style="color:#A6ACCD;">  </span><span style="color:#C3E88D;">--list</span></span></code></pre></div><p>仓库的配置是上面多个配置的集合：</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight has-diff"><code><span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--list</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-l</span></span>
<span class="line"><span style="color:#FFCB6B;">diff.astextplain.textconv</span><span style="color:#A6ACCD;">=astextplain</span></span>
<span class="line"><span style="color:#FFCB6B;">http.sslbackend</span><span style="color:#A6ACCD;">=openssl</span></span>
<span class="line"><span style="color:#FFCB6B;">http.sslcainfo</span><span style="color:#A6ACCD;">=C:/Program </span><span style="color:#C3E88D;">Files/Git/mingw64/ssl/certs/ca-bundle.crt</span></span>
<span class="line"><span style="color:#FFCB6B;">core.autocrlf</span><span style="color:#A6ACCD;">=</span><span style="color:#82AAFF;">true</span></span>
<span class="line"><span style="color:#FFCB6B;">core.fscache</span><span style="color:#A6ACCD;">=</span><span style="color:#82AAFF;">true</span></span>
<span class="line"><span style="color:#FFCB6B;">core.symlinks</span><span style="color:#A6ACCD;">=</span><span style="color:#82AAFF;">false</span></span>
<span class="line"><span style="color:#FFCB6B;">pull.rebase</span><span style="color:#A6ACCD;">=</span><span style="color:#82AAFF;">false</span></span>
<span class="line"><span style="color:#FFCB6B;">credential.helper</span><span style="color:#A6ACCD;">=manager-core</span></span>
<span class="line"><span style="color:#FFCB6B;">credential.https://dev.azure.com.usehttppath</span><span style="color:#A6ACCD;">=</span><span style="color:#82AAFF;">true</span></span>
<span class="line"><span style="color:#FFCB6B;">init.defaultbranch</span><span style="color:#A6ACCD;">=master</span></span>
<span class="line"><span style="color:#FFCB6B;">user.name</span><span style="color:#A6ACCD;">=Kanding</span></span>
<span class="line"><span style="color:#FFCB6B;">user.email</span><span style="color:#A6ACCD;">=123anding@163.com</span></span></code></pre></div><h2 id="免密登录" tabindex="-1">免密登录 <a class="header-anchor" href="#免密登录" aria-label="Permalink to &quot;免密登录&quot;">​</a></h2><p>当安装Git后首先要做的事情是配置你的用户信息—— 告诉Git你是谁？配置 <strong>用户名</strong>、<strong>邮箱地址</strong>，每次提交文件时都会带上这个用户信息，查看历史记录时就知道是谁干的了。<code>--global</code>：<code>config</code>的参数，表示用户全局配置。如果要给特定仓库配置用户信息，则用参数<code>--local</code>配置即可，或直接在仓库配置文件<code>.git/config</code>里修改。</p><p><a href="https://blog.csdn.net/weixin_44748171/article/details/128224747" target="_blank" rel="noreferrer">(191条消息) Git配置免密登录及常用操作的详细教程(基于Gitee平台)_git免密_Wh1T3ZzT的博客-CSDN博客</a></p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--global</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">user.name</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">renshuo</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--global</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">user.email</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">1597374863@qq.com</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 注册 Gitee 账号时填写的邮箱</span></span>
<span class="line"><span style="color:#FFCB6B;">ssh-keygen</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-t</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rsa</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-b</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">4096</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-C</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">1597374863@qq.com</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><blockquote><p>连续敲击 3 次回车，即可在 C:Users\用户名文件夹.ssh 目录中生成 id rsa 和 id rsa.pub 两个文件</p></blockquote><blockquote><p>Linux的在/root/.ssh</p></blockquote><blockquote><p>使用记事本打开 id rsa.pub 文件，复制里面的文本内容</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.6.17/image-20230618094244768.png" alt="image-20230618094244768" style="zoom:80%;"><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">ssh</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-T</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git@gitee.com</span></span></code></pre></div><h1 id="基础命令" tabindex="-1">基础命令 <a class="header-anchor" href="#基础命令" aria-label="Permalink to &quot;基础命令&quot;">​</a></h1><h2 id="基础命令-1" tabindex="-1">基础命令 <a class="header-anchor" href="#基础命令-1" aria-label="Permalink to &quot;基础命令&quot;">​</a></h2><blockquote><p>Git软件是免费、开源的。最初Git软件是为辅助 Linux 内核开发的一套软件，所以在使用时，简单常用的linux系统操作指令是可以直接使用的</p></blockquote><table><thead><tr><th><strong>指令</strong></th><th><strong>含义</strong></th><th><strong>说明</strong></th></tr></thead><tbody><tr><td>cd 目录</td><td>change directory</td><td>改变操作目录</td></tr><tr><td>cd ..</td><td></td><td>退回到上一级目录</td></tr><tr><td>pwd</td><td>Print work directory</td><td>打印工作目录</td></tr><tr><td>ls</td><td>list directory contents</td><td>显示当前目录的文件及子文件目录</td></tr><tr><td>ll</td><td>ls -l 简化版本</td><td>更详细地显示当前目录的文件及子文件目录</td></tr><tr><td>mkdir 文件夹名称</td><td>make directory</td><td>新建一个文件夹</td></tr><tr><td>rm 文件</td><td>remove</td><td>删除文件</td></tr><tr><td>rm -r 文件夹</td><td>Remove</td><td>删除文件目录</td></tr><tr><td>touch 文件</td><td></td><td>如果创建的文件不存在，那么创建一个空文件</td></tr><tr><td>reset</td><td></td><td>清屏</td></tr><tr><td>clear</td><td></td><td>清屏</td></tr><tr><td>exit</td><td></td><td>退出终端窗口</td></tr></tbody></table><h2 id="初始化" tabindex="-1">初始化 <a class="header-anchor" href="#初始化" aria-label="Permalink to &quot;初始化&quot;">​</a></h2><h3 id="帮助命令" tabindex="-1">帮助命令 <a class="header-anchor" href="#帮助命令" aria-label="Permalink to &quot;帮助命令&quot;">​</a></h3><p>git 内置了对命令非常详细的解释，可以供我们快速查阅</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 查找可用命令</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">help</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 查找所有可用命令</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">help</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-a</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 在文档当中查找特定的命令</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># git help &lt;命令&gt;</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">help</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">help</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">help</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">init</span></span></code></pre></div><h3 id="配置信息" tabindex="-1">配置信息 <a class="header-anchor" href="#配置信息" aria-label="Permalink to &quot;配置信息&quot;">​</a></h3><p>作为一个工具软件来讲，一般都会有默认的配置文件来保存基础的配置信息</p><p>Git软件的配置文件位置为：<strong>Git安装路径/etc/gitconfig</strong></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072131044.png" alt="image-20230407213154924" style="zoom:80%;"><p>默认情况下，我们可以通过指令获取软件的配置信息：</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 显示当前的Git配置，git config -l</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--list</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 编辑Git配置文件</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-e</span><span style="color:#A6ACCD;"> [--global]</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 输出、设置基本的全局变量</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--global</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">user.email</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--global</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">user.name</span></span>
<span class="line"></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--global</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">user.email</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">MyEmail@gmail.com</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--global</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">user.name</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">My Name</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 定义当前用户所有提交使用的作者邮箱。</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--global</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">alias.</span><span style="color:#89DDFF;">&lt;</span><span style="color:#C3E88D;">alias-nam</span><span style="color:#A6ACCD;">e</span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#C3E88D;">git-comman</span><span style="color:#A6ACCD;">d</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 为Git命令创建一个快捷方式（别名）。</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--system</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">core.editor</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#C3E88D;">edito</span><span style="color:#A6ACCD;">r</span><span style="color:#89DDFF;">&gt;</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072132716.png" alt="image-20230407213235589" style="zoom:80%;"><h3 id="名称和邮箱" tabindex="-1">名称和邮箱 <a class="header-anchor" href="#名称和邮箱" aria-label="Permalink to &quot;名称和邮箱&quot;">​</a></h3><blockquote><p>如果你是第一回使用Git软件，需要告诉Git软件你的名称和邮箱，否则是无法将文件纳入到版本库中进行版本管理的。这是因为在多人协作时，不同的用户可能对同一个文件进行操作，所以Git软件必须区分不同用户的操作，区分的方式就是名称和邮箱。</p></blockquote><blockquote><p>当然了，你可能会说我就用本地库就行了，不需要进行多人协作，是不是就可以不用配置呢。这是不行的，因为Git软件的设计初衷本身就是针对于linux系统的分布式开发协同工作，所以它天生就是用于分布式协同工作的，这里无论你是否使用这个功能，它本身就是这么设计的。所以是一定要配置的，否则就会出现如下提示：</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072132946.png" alt="image-20230407213251812" style="zoom:80%;"><p>当然了，配置的过程并不复杂，输入相关指令即可</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--global</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">user.name</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">任硕</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--global</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">user.email</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">1597374863</span><span style="color:#C3E88D;">@qq.com</span></span></code></pre></div><blockquote><p>这里的--global表示全局配置，后续的所有文件操作都会使用该用户名称及邮箱。此时在操作系统的用户目录，会产生新的配置文件</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072133539.png" alt="image-20230407213323430" style="zoom:80%;"><p>文件中就包含了刚刚增加的配置信息</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072133453.png" alt="image-20230407213336350" style="zoom:80%;"><h3 id="缓存名称和邮箱" tabindex="-1">缓存名称和邮箱 <a class="header-anchor" href="#缓存名称和邮箱" aria-label="Permalink to &quot;缓存名称和邮箱&quot;">​</a></h3><p>我想缓存一个仓库(repository)的用户名和密码.你可能有一个仓库需要授权，这时你可以缓存用户名和密码，而不用每次推/拉(push/pull)的时候都输入，Credential helper能帮你。</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># Set git to use the credential memory cache  </span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--global</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">credential.helper</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">cache</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># Set the cache to timeout after 1 hour (setting is in seconds)  </span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--global</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">credential.helper</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">cache --timeout=3600</span><span style="color:#89DDFF;">&#39;</span></span></code></pre></div><h2 id="仓库操作" tabindex="-1">仓库操作 <a class="header-anchor" href="#仓库操作" aria-label="Permalink to &quot;仓库操作&quot;">​</a></h2><h3 id="初始化版本库" tabindex="-1">初始化版本库 <a class="header-anchor" href="#初始化版本库" aria-label="Permalink to &quot;初始化版本库&quot;">​</a></h3><blockquote><p>Git软件主要用于管理文件的版本信息，但它只是一个软件，不可能安装后就直接将系统中所有的文件全部纳入到它的管理范畴中。并且，软件管理版本信息的主要目就是管理文件的修改和变更，如果将系统中所有文件都进行管理其实意义是不大的。所以一般情况下，我们需要指定某一个文件目录作为软件的管理目录。因为这个目录主要就作为Git软件的管理文件的版本变化信息，所以这个目录也称之为Git软件的版本仓库目录。</p></blockquote><p>创建一个新的 git 版本库。这个版本库的配置、存储等信息会被保存到.git 文件夹中</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 初始化当前项目</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">init</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 新建一个目录，将其初始化为Git代码库</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">init</span><span style="color:#A6ACCD;"> [project-name]</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 在指定目录创建一个空的 Git 仓库。运行这个命令会创建一个名为 directory，只包含 .git 子目录的空目录。</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">init</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--bare</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#C3E88D;">director</span><span style="color:#A6ACCD;">y</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 下载一个项目和它的整个代码历史</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 这个命令就是将一个版本库拷贝到另一个目录中，同时也将分支都拷贝到新的版本库中。</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 这样就可以在新的版本库中提交到远程分支</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">clone</span><span style="color:#A6ACCD;"> [url]</span></span></code></pre></div><p>版本库创建成功后，会在目录中创建.git目录，用于管理当前版本库。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072134072.png" alt="image-20230407213442960" style="zoom:80%;"><h3 id="向版本库中添加文件" tabindex="-1">向版本库中添加文件 <a class="header-anchor" href="#向版本库中添加文件" aria-label="Permalink to &quot;向版本库中添加文件&quot;">​</a></h3><p>虽然创建了版本库，但是现在版本库中还没有任何的文件，所以这里我们先手动创建文件：test.txt</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072134989.png" alt="image-20230407213457872" style="zoom:80%;"><p>因为文件已经放置在版本库中了。所以可以通过软件的指令查看版本库状态</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">status</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072135661.png" alt="image-20230407213521533" style="zoom:80%;"><p>此时会发现，test.txt文件属于untracked files（未追踪文件）,这里表示当前的test.txt文件虽然放置到了版本库的文件目录中，被Git软件识别到了，但是未纳入到版本库管理中。所以属于未追踪文件。通过这个现象可以认为，系统文件夹物理目录和版本库管理目录的含义是不一样的。只有文件被纳入到版本库管理后，Git软件才能对文件修改后的不同版本内容进行追踪处理，也就是所谓的tracked files了。那么如何将文件纳入到版本库的管理呢，这就需要我们执行以下命令了：</p><p>#这里的文件是需要提供扩展名的</p><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git add test.txt</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072135279.png" alt="image-20230407213544131" style="zoom:80%;"><p>此时你再查看版本库状态，就会发现文件状态的变化。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072136911.png" alt="image-20230407213607780" style="zoom:80%;"><blockquote><p>你会发现，此时文件状态为cached file，这是什么意思呢？其实这也是Git管理文件时的一种状态：暂存状态。就是我们生活中常说的草稿状态。也就是说对于Git来讲，它认为此时文件只是一种临时草稿状态，随时可能会进行修改或删除，并不算真正的操作完成状态。所以并不会把文件纳入到版本库管理中。</p></blockquote><blockquote><p>为什么会这样呢？其实这就涉及到版本的作用。生活中，我们学习时，一般会写学习笔记，虽然写完后不一定会看，但是该写的还是要写的。然后给这些笔记文件起名时，一般就会带着当天的时间或数字。比如【Java学习笔记_20220101.md】，或者【Java学习笔记_Ver1.1.md】，这里的时间或数字主要作用就是用于区分同一份笔记在不同时间节点记录的内容，这里的数字或时间我们就称之为版本。</p></blockquote><blockquote><p>那如果你只是随便写写，还没有写完的话，会专门给文件改个名称吗？应该不会，对不对，因为对于你来讲，这个笔记文件并没有记录完成，对吗。但是你非得说，你今天不想继续学习了，然后给文件改了一个名称，也不是不可以。对于Git软件来讲，道理是一样的。如果确定要把文件放置在版本库中，那么就需要执行确定提交指令</p></blockquote><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># commit表示真正地纳入到版本库中</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># -m 表示提交时的信息（message），是必须输入的。用于描述不同版本之间的差别信息</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-m</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">my first git file</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072136306.png" alt="image-20230407213640165" style="zoom:80%;"><p>再查看Git状态</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072136518.png" alt="image-20230407213654397" style="zoom:80%;"><p>提交后，Git会对当前的操作进行Hash计算，通过计算后的值将数据保存下来，保存的位置为版本库.git文件目录的objects中，我们可以通过指令查看当前提交</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">show</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072137624.png" alt="image-20230407213712496" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072137139.png" alt="image-20230407213727025" style="zoom:80%;"><p>由于文件内容进行了转换处理，直接打开你是看不懂的</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072137794.png" alt="image-20230407213739676" style="zoom:80%;"><h3 id="修改版本库文件" tabindex="-1">修改版本库文件 <a class="header-anchor" href="#修改版本库文件" aria-label="Permalink to &quot;修改版本库文件&quot;">​</a></h3><p>现在文件已经被纳入到版本库中，因为咱们的文件是空的，所以这里我们增加一些内容</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072137540.png" alt="image-20230407213755392" style="zoom:67%;"><p>此时，Git版本库中的文件和本地的文件就有了不同。我们可以查看状态</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072138149.png" alt="image-20230407213810009" style="zoom:80%;"><p><strong>modified</strong>表示文件已经修改了，我们可以把这一次的修改提交到版本库中</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072138095.png" alt="image-20230407213822969" style="zoom:80%;"><p>原则上来讲，这里的操作顺序依然应该是</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 先增加，再提交</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">test.txt</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-m</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">update file</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><p>但是这里我们简化了一下操作</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-a</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-m</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">update file</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><p>这个指令操作中多了一个**-a**的参数，等同于将增加，提交两步操作融合成了一步。提交成功后，我们来展示</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072139578.png" alt="image-20230407213906436" style="zoom:80%;"><h3 id="查看版本库文件历史" tabindex="-1">查看版本库文件历史 <a class="header-anchor" href="#查看版本库文件历史" aria-label="Permalink to &quot;查看版本库文件历史&quot;">​</a></h3><p>版本库中的文件我们已经修改并提交了，那么文件的版本信息就会发生变化，那我们如何来查看这个变化呢？这里我们可以采用log指令进行查看</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072139536.png" alt="image-20230407213926387" style="zoom:80%;"><p>如果感觉看着不舒服，也可以美化一下显示方式:</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--pretty=oneline</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072139476.png" alt="image-20230407213950349" style="zoom:80%;"><p>也可以使用简单方式查看</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--oneline</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072140675.png" alt="image-20230407214003564" style="zoom:80%;"><h3 id="克隆并修改仓库名" tabindex="-1">克隆并修改仓库名 <a class="header-anchor" href="#克隆并修改仓库名" aria-label="Permalink to &quot;克隆并修改仓库名&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">clone</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">xxxxx.git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">new_name</span></span></code></pre></div><h3 id="清理本地仓库" tabindex="-1">清理本地仓库 <a class="header-anchor" href="#清理本地仓库" aria-label="Permalink to &quot;清理本地仓库&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">fetch</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reset</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--hard</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin/master</span></span></code></pre></div><h2 id="文件操作" tabindex="-1">文件操作 <a class="header-anchor" href="#文件操作" aria-label="Permalink to &quot;文件操作&quot;">​</a></h2><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.6.30/202207111854669.png" alt="image-20220711185447601" style="zoom:50%;"><p>在学习常用命令之前，你首先需要知道的 Git 的「三个分区」和对应的文件的「三种状态」：</p><ul><li><code>工作区</code>：就是你本地实际写代码的地方。对应的文件状态是：<code>modified</code>，已修改，但还没保存到数据库中。</li><li><code>暂存区</code>：就是临时存放的地方。对应的文件状态是：<code>staged</code>，Git 已经对该文件做了标记，下次提交知道要包含</li><li><code>本地库</code>：存放本地历史版本信息。对应的文件状态是：<code>committed</code>，文件已经安全的保存在本地数据库中。</li></ul><h3 id="新增文件" tabindex="-1">新增文件 <a class="header-anchor" href="#新增文件" aria-label="Permalink to &quot;新增文件&quot;">​</a></h3><table><thead><tr><th style="text-align:left;"><strong>指令</strong></th><th style="text-align:left;"><strong>描述</strong></th></tr></thead><tbody><tr><td style="text-align:left;">git add [file1] [file2]</td><td style="text-align:left;">添加文件到暂存区，包括修改的文件、新增的文件</td></tr><tr><td style="text-align:left;">git add [dir]</td><td style="text-align:left;">同上，添加目录到暂存区，包括子目录</td></tr><tr><td style="text-align:left;">git add .</td><td style="text-align:left;">同上，添加<strong>所有</strong>修改、新增文件（未跟踪）到暂存区</td></tr><tr><td style="text-align:left;">git rm [file]</td><td style="text-align:left;">删除工作区文件，并且将这次删除放入暂存区</td></tr></tbody></table><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 添加一个文件</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">test.js</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 添加一个子目录中的文件</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/path/to/file/test.js</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 支持正则表达式</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">./</span><span style="color:#A6ACCD;">*</span><span style="color:#C3E88D;">.js</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 添加指定文件到暂存区</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> [file1] </span><span style="color:#89DDFF;">[</span><span style="color:#A6ACCD;">file2</span><span style="color:#89DDFF;">]</span><span style="color:#A6ACCD;"> ...</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 添加指定目录到暂存区，包括子目录</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> [dir]</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 添加当前目录的所有文件到暂存区</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">.</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 添加每个变化前，都会要求确认</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 对于同一个文件的多处变化，可以实现分次提交</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span></span></code></pre></div><h3 id="删除文件" tabindex="-1">删除文件 <a class="header-anchor" href="#删除文件" aria-label="Permalink to &quot;删除文件&quot;">​</a></h3><p>rm 和上面的 add 命令相反，从工作空间中去掉某个文件</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 移除 HelloWorld.js</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rm</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HelloWorld.js</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 移除子目录中的文件</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rm</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/pather/to/the/file/HelloWorld.js</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 删除工作区文件，并且将这次删除放入暂存区</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rm</span><span style="color:#A6ACCD;"> [file1] </span><span style="color:#89DDFF;">[</span><span style="color:#A6ACCD;">file2</span><span style="color:#89DDFF;">]</span><span style="color:#A6ACCD;"> ...</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 停止追踪指定文件，但该文件会保留在工作区</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rm</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--cached</span><span style="color:#A6ACCD;"> [file]</span></span></code></pre></div><h3 id="提交文件" tabindex="-1">提交文件 <a class="header-anchor" href="#提交文件" aria-label="Permalink to &quot;提交文件&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092101960.png" alt="image-20230409210144768" style="zoom:80%;"><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight has-diff"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 提交暂存区到仓库区附带提交信息</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-m</span><span style="color:#A6ACCD;"> [message]</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 提交暂存区的指定文件到仓库区</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> [file1] </span><span style="color:#89DDFF;">[</span><span style="color:#A6ACCD;">file2</span><span style="color:#89DDFF;">]</span><span style="color:#A6ACCD;"> ... -m </span><span style="color:#89DDFF;">[</span><span style="color:#A6ACCD;">message</span><span style="color:#89DDFF;">]</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 提交工作区自上次commit之后的变化，直接到仓库区</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-a</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 提交时显示所有diff信息</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-v</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 使用一次新的commit，替代上一次提交</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 如果代码没有任何新变化，则用来改写上一次commit的提交信息</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--amend</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-m</span><span style="color:#A6ACCD;"> [message]</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 重做上一次commit，并包括指定文件的新变化</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--amend</span><span style="color:#A6ACCD;"> [file1] </span><span style="color:#89DDFF;">[</span><span style="color:#A6ACCD;">file2</span><span style="color:#89DDFF;">]</span><span style="color:#A6ACCD;"> ...</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 编辑上次提交</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--amend</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-m</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">更好的提交日志</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 在上次提交中附加一些内容，保持提交日志不变</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">.</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&amp;&amp;</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--amend</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--no-edit</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 空提交 —— 可以用来重新触发 CI 构建</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--allow-empty</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-m</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">chore:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">re-trigger</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">build</span></span></code></pre></div><h3 id="删除文件-1" tabindex="-1">删除文件 <a class="header-anchor" href="#删除文件-1" aria-label="Permalink to &quot;删除文件&quot;">​</a></h3><blockquote><p>一般情况下，Git软件就是用于管理文件的版本变更，但是在一些特殊的场景中，文件可能作废或不再使用，那么就需要从版本库中删除，记住，这里说的并不是从物理文件目录中删除，而是从版本库中删除。</p></blockquote><p>将本地文件从目录中删除</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072140716.png" alt="image-20230407214017590" style="zoom:80%;"><p>查看Git版本库状态信息</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072140856.png" alt="image-20230407214034718" style="zoom:80%;"><blockquote><p>此时Git软件会识别出来，版本库中有一份文件和当前用于临时操作文件的暂存区内的文件状态不一致：版本库中文件还在，但是操作区内的文件已经没有了。所以软件提供了两个选择：一个是将版本库中的文件也进行（提交）删除操作。另外一个就是从版本库中恢复文件。</p></blockquote><p>使用指令从版本库中恢复文件</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">restore</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">test.txt</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072140253.png" alt="image-20230407214054129" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072141511.png" alt="image-20230407214104398" style="zoom:80%;"><p>如果想要真正删除文件，那么也要将版本库中同时删除，就是直接提交即可</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-a</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-m</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">第n次提交，删除了某文件</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072141353.png" alt="image-20230407214131224" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072141312.png" alt="image-20230407214149163" style="zoom:80%;"><p>此时查看Git日志</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072142725.png" alt="image-20230407214203584" style="zoom:80%;"><h3 id="重命名或移动" tabindex="-1">重命名或移动 <a class="header-anchor" href="#重命名或移动" aria-label="Permalink to &quot;重命名或移动&quot;">​</a></h3><p>重命名或移动一个文件</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 重命名</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mv</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">test.js</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">test2.js</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 移动</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mv</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">test.js</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">./new/path/test.js</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 改名文件，并且将这个改名放入暂存区</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mv</span><span style="color:#A6ACCD;"> [file-original] </span><span style="color:#89DDFF;">[</span><span style="color:#A6ACCD;">file-renamed</span><span style="color:#89DDFF;">]</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 强制重命名或移动</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 这个文件已经存在，将要覆盖掉</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mv</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-f</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">myFile</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">existingFile</span></span></code></pre></div><h3 id="提交标准" tabindex="-1">提交标准 <a class="header-anchor" href="#提交标准" aria-label="Permalink to &quot;提交标准&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304231643272.png" alt="image-20230423164358153" style="zoom:80%;"><h2 id="状态信息" tabindex="-1">状态信息 <a class="header-anchor" href="#状态信息" aria-label="Permalink to &quot;状态信息&quot;">​</a></h2><p>获取某些文件，某些分支，某次提交等 git 信息</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight has-diff"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 显示commit历史，以及每次commit发生变更的文件</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--stat</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 搜索提交历史，根据关键词</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-S</span><span style="color:#A6ACCD;"> [keyword]</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 显示某个commit之后的所有变动，每个commit占据一行</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> [tag] HEAD --pretty=format:%s</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 显示某个commit之后的所有变动，其&quot;提交说明&quot;必须符合搜索条件</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> [tag] HEAD --grep feature</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 显示某个文件的版本历史，包括文件改名</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--follow</span><span style="color:#A6ACCD;"> [file]</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">whatchanged</span><span style="color:#A6ACCD;"> [file]</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 显示指定文件相关的每一次diff</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span><span style="color:#A6ACCD;"> [file]</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 显示过去5次提交</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-5</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--pretty</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--oneline</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 显示所有提交过的用户，按提交次数排序</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">shortlog</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-sn</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 显示指定文件是什么人在什么时间修改过</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">blame</span><span style="color:#A6ACCD;"> [file]</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 显示暂存区和工作区的差异</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">diff</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 显示暂存区和上一个commit的差异</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">diff</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--cached</span><span style="color:#A6ACCD;"> [file]</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 显示工作区与当前分支最新commit之间的差异</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">diff</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HEAD</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 显示两次提交之间的差异</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">diff</span><span style="color:#A6ACCD;"> [first-branch]...</span><span style="color:#89DDFF;">[</span><span style="color:#A6ACCD;">second-branch</span><span style="color:#89DDFF;">]</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 显示今天你写了多少行代码</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">diff</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--shortstat</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">@{0 day ago}</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 比较暂存区和版本库差异</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">diff</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--staged</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 比较暂存区和版本库差异</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">diff</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--cached</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 仅仅比较统计信息</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">diff</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--stat</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 显示某次提交的元数据和内容变化</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">show</span><span style="color:#A6ACCD;"> [commit]</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 显示某次提交发生变化的文件</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">show</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--name-only</span><span style="color:#A6ACCD;"> [commit]</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 显示某次提交时，某个文件的内容</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">show</span><span style="color:#A6ACCD;"> [commit]:</span><span style="color:#89DDFF;">[</span><span style="color:#A6ACCD;">filename</span><span style="color:#89DDFF;">]</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 显示当前分支的最近几次提交</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reflog</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 查看远程分支</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">br</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-r</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 创建新的分支</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">br</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#C3E88D;">new_branc</span><span style="color:#A6ACCD;">h</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 查看各个分支最后提交信息</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">br</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-v</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 查看已经被合并到当前分支的分支</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">br</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--merged</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 查看尚未被合并到当前分支的分支</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">br</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--no-merged</span></span></code></pre></div><h3 id="查看工作区状态" tabindex="-1">查看工作区状态 <a class="header-anchor" href="#查看工作区状态" aria-label="Permalink to &quot;查看工作区状态&quot;">​</a></h3><p>作用：<code>查看的修改的状态（暂存区、工作区）</code></p><p>git status,表示查看工作区状态，使用命令格式：</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">status</span><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;"># 查看当前工作区暂存区变动</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">status</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-s</span><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;"># 查看当前工作区暂存区变动，概要信息</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">status</span><span style="color:#A6ACCD;">  </span><span style="color:#C3E88D;">--show-stash</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;"># 查询工作区中是否有stash（暂存的文件）</span></span></code></pre></div><blockquote><p>当你忘记是否已把代码文件添加到暂存区或者是否提交到本地仓库，都可以用git status看看哦~</p></blockquote><h3 id="查看提交记录" tabindex="-1">查看提交记录 <a class="header-anchor" href="#查看提交记录" aria-label="Permalink to &quot;查看提交记录&quot;">​</a></h3><p>查看到提交过的信息，从近到远显示每次 commit 的 comment 还有作者、日期等信息</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight has-diff"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 显示所有提交</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 以精简模式显示查看提交历史</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--oneline</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 显示某几条提交信息</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-n</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">10</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 仅显示合并提交</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--merges</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 查看该文件每次提交记录</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#C3E88D;">fil</span><span style="color:#A6ACCD;">e</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 查看每次详细修改内容的diff</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#C3E88D;">fil</span><span style="color:#A6ACCD;">e</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 查看最近两次详细修改内容的diff</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-2</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">#查看提交统计信息</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--stat</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 以精简模式显示查看提交历史</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reflog</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 在所有提交日志中搜索包含「homepage」的提交</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--all</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--grep=</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">homepage</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 获取某人的提交日志</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--author=Maxence</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img/image-20210930171001888.png" alt="image-20210930171001888" style="zoom:80%;"><h3 id="文件比较" tabindex="-1">文件比较 <a class="header-anchor" href="#文件比较" aria-label="Permalink to &quot;文件比较&quot;">​</a></h3><p><code>git diff</code>用来比较不同文件版本之间的差异。</p><table><thead><tr><th style="text-align:left;"><strong>指令</strong></th><th style="text-align:left;"><strong>描述</strong></th></tr></thead><tbody><tr><td style="text-align:left;"><strong>git diff</strong></td><td style="text-align:left;">查看暂存区和工作区的差异</td></tr><tr><td style="text-align:left;">git diff [file]</td><td style="text-align:left;">同上，指定文件</td></tr><tr><td style="text-align:left;">git diff --cached</td><td style="text-align:left;">查看已暂存的改动，就是暂存区与新版本<code>HEAD</code>进行比较</td></tr><tr><td style="text-align:left;">git diff --staged</td><td style="text-align:left;">同上</td></tr><tr><td style="text-align:left;">git diff --cached [file]</td><td style="text-align:left;">同上，指定文件</td></tr><tr><td style="text-align:left;">git diff HEAD</td><td style="text-align:left;">查看已暂存的+未暂存的所有改动，就是与最新版本<code>HEAD</code>进行比较</td></tr><tr><td style="text-align:left;">git diff HEAD~</td><td style="text-align:left;">同上，与上一个版本比较。<code>HEAD~</code>表示上一个版本，<code>HEAD~10</code>为最近第10个版本</td></tr><tr><td style="text-align:left;">git diff [id] [id]</td><td style="text-align:left;">查看两次提交之间的差异</td></tr><tr><td style="text-align:left;">git diff [branch]</td><td style="text-align:left;">查看工作区和分支直接的差异</td></tr></tbody></table><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight has-diff"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 查看文件的修改</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">diff</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">README.md</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 查看两次提交的差异</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">diff</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">8</span><span style="color:#C3E88D;">f4244</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">1</span><span style="color:#C3E88D;">da22</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 显示今天你写了多少行代码：工作区+暂存区</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">diff</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--shortstat</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">@{0 day ago}</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092102455.png" alt="image-20230409210255260" style="zoom:80%;"><h3 id="拣选提交" tabindex="-1">拣选提交 <a class="header-anchor" href="#拣选提交" aria-label="Permalink to &quot;拣选提交&quot;">​</a></h3><blockquote><p>cherry-pick：当有一个紧急bug，在<code>dev</code>上修复完，我们需要把<code>dev</code>上的这个bug修复所做的修改“复制”到<code>master</code>分支，但不想把整个dev合并过去。为了方便操作，Git专门提供了一个<code>cherry-pick</code>命令，让我们能复制一个特定的提交到当前分支，而不管这个提交在哪个分支。</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092200982.png" alt="image-20230409220025757" style="zoom:80%;"><p>如上操作过程相当于将该提交导出为补丁文件，然后在当前<code>HEAD</code>上重放，形成无论内容还是提交说明都一致的提交</p><ul><li>希望把<code>dev</code>分支上的<code>v7</code>提交的内容合并到<code>master</code>，但不需要其他的内容。</li><li>在<code>master</code>分支上执行指令<code>git cherry-pick v7</code>，会产生一个新的<code>v7&#39;</code>提交，内容和<code>v7</code>相同。</li><li>同时更新<code>master</code>、<code>HEAD</code>，以及工作区。</li></ul><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 选择一个commit，合并进当前分支</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">cherry-pick</span><span style="color:#A6ACCD;"> [commit]</span></span></code></pre></div><h2 id="暂存" tabindex="-1">暂存 <a class="header-anchor" href="#暂存" aria-label="Permalink to &quot;暂存&quot;">​</a></h2><blockquote><p>当你正在<code>dev</code>分支开发一个功能时，代码写了一半，突然有一个线上的bug急需要马上修改。<code>dev</code>分支Bug没写完，不方便提交，就不能切换到主分支去修复线上bug。Git提供一个<code>stash</code>功能，可以把当前<strong>工作区、暂存区</strong> 未提交的内容“隐藏”起来，就像什么都没发生一样。</p></blockquote><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight has-diff"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 有未提交修改，切换分支时报错</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">dev</span></span>
<span class="line"><span style="color:#FFCB6B;">error:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">Your</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">local</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">changes</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">to</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">the</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">following</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">files</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">would</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">be</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">overwritten</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">by</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout:</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">README.md</span></span>
<span class="line"><span style="color:#FFCB6B;">Please</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">your</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">changes</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">or</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">stash</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">them</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">before</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">you</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">switch</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">branches.</span></span>
<span class="line"><span style="color:#FFCB6B;">Aborting</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 隐藏</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">stash</span></span>
<span class="line"><span style="color:#FFCB6B;">Saved</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">working</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">directory</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">and</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">index</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">state</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">WIP</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">on</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">main:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">2</span><span style="color:#C3E88D;">bc012c</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">s</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 查看被隐藏的内容</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">stash</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">list</span></span>
<span class="line"><span style="color:#FFCB6B;">stash@</span><span style="color:#A6ACCD;">{0}</span><span style="color:#82AAFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">WIP</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">on</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">main:</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">2</span><span style="color:#C3E88D;">bc012c</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">s</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 比较一下，什么都没有，一切都没有发生过！</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">diff</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 去其他分支修改bug，修复完成回到当前分支，恢复工作区</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">stash</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">pop</span></span></code></pre></div><p>在上面示例中，有未提交修改，切换分支时报错。错误提示信息很明确了，<code>commit</code>提交或<code>stash</code>隐藏：<code>Please commit your changes or stash them before you switch branches.</code></p><blockquote><p>📢 如果切换分支时，未提交修改的内容没有冲突，是可以成功切换的，未提交修改会被带过去。</p></blockquote><table><thead><tr><th style="text-align:left;"><strong>指令</strong></th><th style="text-align:left;"><strong>描述</strong></th></tr></thead><tbody><tr><td style="text-align:left;">git stash</td><td style="text-align:left;">把未提交内容隐藏起来，包括未暂存、已暂存。等以后恢复现场后继续工作</td></tr><tr><td style="text-align:left;">git stash list</td><td style="text-align:left;">查看所有被隐藏的内容列表</td></tr><tr><td style="text-align:left;">git stash pop</td><td style="text-align:left;">恢复被隐藏的内容，同时删除隐藏记录</td></tr><tr><td style="text-align:left;">git stash save &quot;message&quot;</td><td style="text-align:left;">同<code>git stash</code>，可以备注说明<code>message</code></td></tr><tr><td style="text-align:left;">git stash apply</td><td style="text-align:left;">恢复被隐藏的文件，但是隐藏记录不删除</td></tr><tr><td style="text-align:left;">git stash drop</td><td style="text-align:left;">删除隐藏记录</td></tr></tbody></table><blockquote><p>当然这里先提交到本地也是可以的，只是提交不是一个完整的功能代码，而是残缺的一部分，影响也不大。</p></blockquote><h3 id="暂存所有改动" tabindex="-1">暂存所有改动 <a class="header-anchor" href="#暂存所有改动" aria-label="Permalink to &quot;暂存所有改动&quot;">​</a></h3><p>暂存你工作目录下的所有改动</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git stash</span></span></code></pre></div><p>你可以使用<code>-u</code>来排除一些文件</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git stash </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">u</span></span></code></pre></div><h3 id="暂存指定文件" tabindex="-1">暂存指定文件 <a class="header-anchor" href="#暂存指定文件" aria-label="Permalink to &quot;暂存指定文件&quot;">​</a></h3><p>假设你只想暂存某一个文件</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git stash push filename</span></span></code></pre></div><p>假设你想暂存多个文件</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git stash push filename1</span><span style="color:#F78C6C;">.ext</span><span style="color:#A6ACCD;"> filename2</span><span style="color:#F78C6C;">.ext</span></span></code></pre></div><h3 id="暂存时记录消息" tabindex="-1">暂存时记录消息 <a class="header-anchor" href="#暂存时记录消息" aria-label="Permalink to &quot;暂存时记录消息&quot;">​</a></h3><p>这样你可以在<code>list</code>时看到它</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git stash save </span><span style="color:#89DDFF;">&lt;</span><span style="color:#A6ACCD;">message</span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">git stash push </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">m </span><span style="color:#89DDFF;">&lt;</span><span style="color:#A6ACCD;">message</span><span style="color:#89DDFF;">&gt;</span></span></code></pre></div><h3 id="使用某个指定暂存" tabindex="-1">使用某个指定暂存 <a class="header-anchor" href="#使用某个指定暂存" aria-label="Permalink to &quot;使用某个指定暂存&quot;">​</a></h3><p>首先你可以查看你的<code>stash</code>记录</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git stash list</span></span></code></pre></div><p>然后你可以<code>apply</code>某个<code>stash</code></p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git stash apply </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">stash@{n}</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><p>此处， &#39;n&#39;是<code>stash</code>在栈中的位置，最上层的<code>stash</code>会是0</p><p>除此之外，也可以使用时间标记(假如你能记得的话)。</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git stash apply </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">stash@{2.hours.ago}</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><h3 id="暂存时保留未暂存的内容" tabindex="-1">暂存时保留未暂存的内容 <a class="header-anchor" href="#暂存时保留未暂存的内容" aria-label="Permalink to &quot;暂存时保留未暂存的内容&quot;">​</a></h3><p>你需要手动create一个<code>stash commit</code>， 然后使用<code>git stash store</code>。</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git stash create  </span></span>
<span class="line"><span style="color:#A6ACCD;">git stash store </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">m </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">commit-message</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> CREATED_SHA1</span></span></code></pre></div><p>多数情况下，你应该将所有的内容变为未暂存，然后再选择你想要的内容进行commit。但假定你就是想要这么做，这里你可以创建一个临时的commit来保存你已暂存的内容，然后暂存你的未暂存的内容并进行stash。然后reset最后一个commit将原本暂存的内容变为未暂存，最后stash pop回来。</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">$ git commit </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">m </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">WIP</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">$ git add </span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">$ git stash  </span></span>
<span class="line"><span style="color:#A6ACCD;">$ git reset HEAD^  </span></span>
<span class="line"><span style="color:#A6ACCD;">$ git stash pop </span><span style="color:#89DDFF;">--</span><span style="color:#A6ACCD;">index </span><span style="color:#F78C6C;">0</span></span></code></pre></div><p>注意1: 这里使用<code>pop</code>仅仅是因为想尽可能保持幂等。注意2: 假如你不加上<code>--index</code>你会把暂存的文件标记为为存储。</p><p>未暂存(Unstaged)的内容</p><p>我想把未暂存的内容移动到一个新分支</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">$ git checkout </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">b my</span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">branch</span></span></code></pre></div><p>我想把未暂存的内容移动到另一个已存在的分支</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">$ git stash  </span></span>
<span class="line"><span style="color:#A6ACCD;">$ git checkout my</span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">branch  </span></span>
<span class="line"><span style="color:#A6ACCD;">$ git stash pop</span></span></code></pre></div><p>我想丢弃本地未提交的变化(uncommitted changes)</p><p>如果你只是想重置源(origin)和你本地(local)之间的一些提交(commit)，你可以：</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> one commit  </span></span>
<span class="line"><span style="color:#89DDFF;">(</span><span style="color:#A6ACCD;">my</span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">branch</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;">$ git reset </span><span style="color:#89DDFF;">--</span><span style="color:#A6ACCD;">hard HEAD^  </span></span>
<span class="line"><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> two commits  </span></span>
<span class="line"><span style="color:#89DDFF;">(</span><span style="color:#A6ACCD;">my</span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">branch</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;">$ git reset </span><span style="color:#89DDFF;">--</span><span style="color:#A6ACCD;">hard HEAD^^  </span></span>
<span class="line"><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> four commits  </span></span>
<span class="line"><span style="color:#89DDFF;">(</span><span style="color:#A6ACCD;">my</span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">branch</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;">$ git reset </span><span style="color:#89DDFF;">--</span><span style="color:#A6ACCD;">hard HEAD</span><span style="color:#89DDFF;">~</span><span style="color:#F78C6C;">4</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> or  </span></span>
<span class="line"><span style="color:#89DDFF;">(</span><span style="color:#A6ACCD;">main</span><span style="color:#89DDFF;">)</span><span style="color:#A6ACCD;">$ git checkout </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">f</span></span></code></pre></div><p>重置某个特殊的文件, 你可以用文件名做为参数:</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">$ git reset filename</span></span></code></pre></div><p>我想丢弃某些未暂存的内容</p><p>如果你想丢弃工作拷贝中的一部分内容，而不是全部。</p><p>签出(checkout)不需要的内容，保留需要的。</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">$ git checkout </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">p  </span></span>
<span class="line"><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> Answer y to all of the snippets you want to drop</span></span></code></pre></div><p>另外一个方法是使用 <code>stash</code>， Stash所有要保留下的内容, 重置工作拷贝, 重新应用保留的部分。</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">$ git stash </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">p  </span></span>
<span class="line"><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> Select all of the snippets you want to save  </span></span>
<span class="line"><span style="color:#A6ACCD;">$ git reset </span><span style="color:#89DDFF;">--</span><span style="color:#A6ACCD;">hard  </span></span>
<span class="line"><span style="color:#A6ACCD;">$ git stash pop</span></span></code></pre></div><p>或者, stash 你不需要的部分, 然后stash drop。</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">$ git stash </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">p  </span></span>
<span class="line"><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> Select all of the snippets you don</span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">t want to save  </span></span>
<span class="line"><span style="color:#A6ACCD;">$ git stash drop</span></span></code></pre></div><h2 id="命令别名" tabindex="-1">命令别名 <a class="header-anchor" href="#命令别名" aria-label="Permalink to &quot;命令别名&quot;">​</a></h2><p>对我这种喜欢敲命令而不用图形化工具的爱好者来说，设置短命令可以很好的提高效率。</p><p>方式一：直接命令行配置</p><div class="language-scss"><button title="Copy Code" class="copy"></button><span class="lang">scss</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git config --global alias</span><span style="color:#89DDFF;">.</span><span style="color:#FFCB6B;">ps</span><span style="color:#A6ACCD;"> push</span></span></code></pre></div><p>方式二：全局配置文件</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">vim</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">~/.gitconfig</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight has-diff"><code><span class="line"><span style="color:#89DDFF;">[</span><span style="color:#A6ACCD;">alias</span><span style="color:#89DDFF;">]</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">co</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">ps</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">pl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">pull</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">mer</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">merge</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--no-ff</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">cp</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">cherry-pick</span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">a</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">amend</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--amend</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">c</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">ca</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--amend</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">ci</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-a</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">co</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">d</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">diff</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">dc</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">diff</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--changed</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">ds</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">diff</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--staged</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">f</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">fetch</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">loll</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--graph</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--decorate</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--pretty=oneline</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--abbrev-commit</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">m</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">merge</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">one</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--pretty=oneline</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">outstanding</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rebase</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-i</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">@{u}</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">s</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">status</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">unpushed</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">@{u}</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">wc</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">whatchanged</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">wip</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rebase</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-i</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">@{u}</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#A6ACCD;">        </span><span style="color:#FFCB6B;">zap</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">fetch</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 使用等同于 git cherry-pick &lt;commitHash&gt;</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">cp</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#C3E88D;">commitHas</span><span style="color:#A6ACCD;">h</span><span style="color:#89DDFF;">&gt;</span></span></code></pre></div><h2 id="忽略列表" tabindex="-1">忽略列表 <a class="header-anchor" href="#忽略列表" aria-label="Permalink to &quot;忽略列表&quot;">​</a></h2><blockquote><p>工作目录中的文件并不是全都需要纳入版本管理，如日志、临时文件、私有配置文件等不需要也不能纳入版本管理，那该怎么办呢？ 各种语言项目的常用<code>.gitignore</code>文件配置：<a href="https://github.com/github/gitignore" target="_blank" rel="noreferrer">https://github.com/github/gitignore</a></p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092058117.png" alt="image-20230409205805943" style="zoom:80%;"><p>在工作区根目录下创建“<code>.gitignore</code>”文件，文件中配置不需要进行版本管理的文件、文件夹。“<code>.gitignore</code>”文件本身是被纳入版本管理的，可以共享。有如下规则：</p><blockquote><ul><li><code>#</code>符号开头为注释</li><li>可以使用Linux通配符。星号（*）代表任意多个字符，问号（？）代表一个字符，方括号（[abc]）代表可选字符范围，大括号（{string1,string2,...}）代表可选的字符串等。</li><li>感叹号（<code>!</code>）开头：表示例外规则，将不被忽略。</li><li>路径分隔符（/f）<strong>开头</strong>：，表示要忽略<strong>根目录</strong>下的<strong>文件</strong><code>f</code>。</li><li>路径分隔符（f/）<strong>结尾</strong>：，表示要忽略<strong>文件夹</strong><code>f</code>下面的所有文件。</li></ul></blockquote><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> 忽略所有“</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">txt”结尾的文件</span></span>
<span class="line"><span style="color:#89DDFF;">*.</span><span style="color:#A6ACCD;">txt </span></span>
<span class="line"><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> lib</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">txt除外</span></span>
<span class="line"><span style="color:#89DDFF;">!</span><span style="color:#A6ACCD;">lib</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">txt  </span></span>
<span class="line"><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> 仅忽略项目根目录下的temp文件</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;">不包括其它目录下的temp，如不包括“src</span><span style="color:#89DDFF;">/</span><span style="color:#A6ACCD;">temp”</span></span>
<span class="line"><span style="color:#89DDFF;">/</span><span style="color:#A6ACCD;">temp  </span></span>
<span class="line"><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> 忽略build</span><span style="color:#89DDFF;">/</span><span style="color:#A6ACCD;">目录下的所有文件</span></span>
<span class="line"><span style="color:#A6ACCD;">build</span><span style="color:#89DDFF;">/</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> 会忽略 doc</span><span style="color:#89DDFF;">/</span><span style="color:#A6ACCD;">notes</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">txt 但不包括 doc</span><span style="color:#89DDFF;">/</span><span style="color:#A6ACCD;">server</span><span style="color:#89DDFF;">/</span><span style="color:#A6ACCD;">arch</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">txt</span></span>
<span class="line"><span style="color:#A6ACCD;">doc</span><span style="color:#89DDFF;">/*.</span><span style="color:#A6ACCD;">txt </span></span>
<span class="line"><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> 所有以</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">md结尾的文件</span></span>
<span class="line"><span style="color:#89DDFF;">*.</span><span style="color:#A6ACCD;">md  </span></span>
<span class="line"><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> lib</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">a不能被忽略</span></span>
<span class="line"><span style="color:#89DDFF;">!</span><span style="color:#A6ACCD;">lib</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">a</span></span>
<span class="line"><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> node_modules和</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">vscode文件被忽略</span></span>
<span class="line"><span style="color:#A6ACCD;">node_modules</span></span>
<span class="line"><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">vscode</span></span>
<span class="line"><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> build目录下的文件被忽略</span></span>
<span class="line"><span style="color:#A6ACCD;">build</span><span style="color:#89DDFF;">/</span></span>
<span class="line"><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> doc目录下的</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">txt文件被忽略</span></span>
<span class="line"><span style="color:#A6ACCD;">doc</span><span style="color:#89DDFF;">/*.</span><span style="color:#A6ACCD;">txt</span></span>
<span class="line"><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> doc目录下多层目录的所有以</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">pdf结尾的文件被忽略</span></span>
<span class="line"><span style="color:#A6ACCD;">doc</span><span style="color:#89DDFF;">/**/*.</span><span style="color:#A6ACCD;">pdf</span></span></code></pre></div><h2 id="恢复历史文件" tabindex="-1">恢复历史文件 <a class="header-anchor" href="#恢复历史文件" aria-label="Permalink to &quot;恢复历史文件&quot;">​</a></h2><p><a href="https://mp.weixin.qq.com/s?__biz=MzU2MTIyNDUwMA==&amp;mid=2247514004&amp;idx=1&amp;sn=f59dda5ce7617d0bb2e55eb3f9120235&amp;chksm=fc7ef9cfcb0970d9d8ed550de941c97115701411668540f87e42fc1fe465cd33c4b69e02aadd&amp;mpshare=1&amp;scene=23&amp;srcid=04260hxkQrRAorpB13utjrNk&amp;sharer_sharetime=1682482816688&amp;sharer_shareid=29b8a04db1dbd975e3bf4e9f47e7ac67#rd" target="_blank" rel="noreferrer">在 Git 中撤消更改的 6 种方法！</a></p><blockquote><p>Git的撤销与回退，在日常工作中使用的比较频繁。比如我们想将某个修改后的文件撤销到上一个版本，或者想撤销某次多余的提交，都要用到git的撤销和回退操作。代码在Git的每个工作区域都是用哪些命令撤销或者回退的呢</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.6.30/202207231838832.png" alt="image-20220723183809725" style="zoom:67%;"><table><thead><tr><th style="text-align:left;">**指令 **</th><th style="text-align:left;"><strong>描述</strong></th></tr></thead><tbody><tr><td style="text-align:left;">git checkout .</td><td style="text-align:left;">撤销工作区的（未暂存）修改，把暂存区恢复到工作区。不影响暂存区，如果没暂存，则撤销所有工作区修改</td></tr><tr><td style="text-align:left;">git checkout [file]</td><td style="text-align:left;">同上，<code>file</code>指定文件</td></tr><tr><td style="text-align:left;">git checkout HEAD .</td><td style="text-align:left;">撤销工作区、暂存区的修改，用<code>HEAD</code>指向的当前分支最新版本替换工作区、暂存区</td></tr><tr><td style="text-align:left;">git checkout HEAD [file]</td><td style="text-align:left;">同上，<code>file</code>指定文件</td></tr><tr><td style="text-align:left;">git reset</td><td style="text-align:left;">撤销暂存区状态，同<code>git reset HEAD</code>，不影响工作区</td></tr><tr><td style="text-align:left;">git reset HEAD [file]</td><td style="text-align:left;">同上，指定文件<code>file</code>，<code>HEAD</code>可省略</td></tr><tr><td style="text-align:left;">git reset [commit]</td><td style="text-align:left;">回退到指定版本，清空暂存区，不影响工作区。工作区需要手动<code>git checkout</code>签出</td></tr><tr><td style="text-align:left;">git reset --soft [commit]</td><td style="text-align:left;">移动分支<code>master</code>、<code>HEAD</code>到指定的版本，不影响暂存区、工作区，需手动<code>git checkout</code>签出更新</td></tr><tr><td style="text-align:left;">git reset --hard HEAD</td><td style="text-align:left;">撤销工作区、暂存区的修改，用当前最新版</td></tr><tr><td style="text-align:left;">git reset --hard HEAD~</td><td style="text-align:left;">回退到上一个版本，并重置工作区、暂存区内容。</td></tr><tr><td style="text-align:left;">git reset --hard [commit]</td><td style="text-align:left;">回退到指定版本，并重置工作区、暂存区内容。</td></tr><tr><td style="text-align:left;">git <strong>revert</strong>[commit]</td><td style="text-align:left;">撤销一个提交，会用一个新的提交（原提交的逆向操作）来完成撤销操作，如果已<code>push</code>则重新<code>push</code>即可</td></tr></tbody></table><ul><li><code>git checkout .</code>、<code>git checkout [file]</code> 会清除工作区中未添加到暂存区的修改，用暂存区内容替换工作区。</li><li><code>git checkout HEAD .</code>、<code>git checkout HEAD [file]</code> 会清除工作区、暂存区的修改，用HEAD指向的当前分支最新版本替换暂存区、工作区。</li></ul><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 获取所有操作历史</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reflog</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 重置到相应提交</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reset</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HEAD@{</span><span style="color:#F78C6C;">4</span><span style="color:#C3E88D;">}</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># ……或者……</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reset</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--hard</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#C3E88D;">提交的哈希</span><span style="color:#A6ACCD;">值</span><span style="color:#89DDFF;">&gt;</span></span></code></pre></div><table><thead><tr><th style="text-align:left;"><strong>标题 \ 指令</strong></th><th style="text-align:left;"><strong>checkout</strong></th><th style="text-align:left;"><strong>reset</strong></th><th style="text-align:left;"><strong>revert</strong></th></tr></thead><tbody><tr><td style="text-align:left;"><strong>主要作用（撤销）</strong></td><td style="text-align:left;">撤销工作区、暂存区未提交修改</td><td style="text-align:left;">回退版本，重置工作区、暂存区</td><td style="text-align:left;">撤销某一次提交</td></tr><tr><td style="text-align:left;"><strong>撤销工作区</strong></td><td style="text-align:left;">git checkout [file]</td><td style="text-align:left;">git reset HEAD [file]</td><td style="text-align:left;"></td></tr><tr><td style="text-align:left;"><strong>撤销工作区、暂存区</strong></td><td style="text-align:left;">git checkout HEAD [file]</td><td style="text-align:left;">git reset --hard HEAD [file]</td><td style="text-align:left;"></td></tr><tr><td style="text-align:left;"><strong>回退版本</strong></td><td style="text-align:left;"></td><td style="text-align:left;">git reset --hard [commit]</td><td style="text-align:left;"></td></tr><tr><td style="text-align:left;"><strong>安全性</strong></td><td style="text-align:left;">只针对未提交修改，<strong>安全</strong></td><td style="text-align:left;">如回退了已<code>push</code>提交，<strong>不安全</strong></td><td style="text-align:left;"><strong>安全</strong></td></tr></tbody></table><p>可看出<code>reset</code>完全可以替代<code>checkout</code>来执行撤销、回退操作，<code>reset</code>本来也是专门用来干这个事情的，可以抛弃<code>checkout</code>了（撤销的时候）。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092121409.png" alt="image-20230409212116177" style="zoom:80%;"><h3 id="git-reset" tabindex="-1">git reset <a class="header-anchor" href="#git-reset" aria-label="Permalink to &quot;git reset&quot;">​</a></h3><h4 id="基本概述-1" tabindex="-1">基本概述 <a class="header-anchor" href="#基本概述-1" aria-label="Permalink to &quot;基本概述&quot;">​</a></h4><blockquote><p>将当前的头指针复位到一个特定的状态。这样可以使你撤销 merge、pull、commits、add 等这是个很强大的命令，但是在使用时一定要清楚其所产生的后果</p></blockquote><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 使 staging 区域恢复到上次提交时的状态，不改变现在的工作目录</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reset</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 使 staging 区域恢复到上次提交时的状态，覆盖现在的工作目录</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reset</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--hard</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 将当前分支恢复到某次提交，不改变现在的工作目录</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 在工作目录中所有的改变仍然存在</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reset</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">dha78as</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 将当前分支恢复到某次提交，覆盖现在的工作目录</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 并且删除所有未提交的改变和指定提交之后的所有提交</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reset</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--hard</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">dha78as</span></span></code></pre></div><blockquote><p><strong>如果版本库中一份文件中已经被删除了，那么此时这份文件还能找回来吗</strong>？其实原则上来讲，已经不行了，因为文件删除本身也是一种变更操作，也算是版本库管理的一部分。所以想要将已经删除的那份文件从版本库中取出来，已经是不可能了。<code>reset</code>是专门用来撤销修改、回退版本的指令，支持的场景比较多，多种撤销姿势，所以参数组合也比较多。简单理解就是移动<code>master</code>分支、<code>HEAD</code>的“指针”地址，理解这一点就基本掌握<code>reset</code>了</p></blockquote><blockquote><p>但是，要注意的是，版本库管理的是文件不同版本的变更操作，这个不同版本的概念还是非常重要的。也就是说，<strong>最后的那个删除的文件版本已经没有了，但是之前版本的文件其实还是存在的</strong>。<strong>所以如果我们能将文件恢复到某一个版本，那么那个版本的文件就依然存在</strong>。</p></blockquote><h4 id="图解概述" tabindex="-1">图解概述 <a class="header-anchor" href="#图解概述" aria-label="Permalink to &quot;图解概述&quot;">​</a></h4><p>回退版本<code>git reset --hard v4</code> 或 <code>git reset --hard HEAD~2</code>，<code>master</code>、<code>HEAD</code>会指向<code>v4</code>提交，<code>v5</code>、<code>v6</code>就被废弃了。也可以重新恢复到<code>v6</code>版本：<code>git reset --hard v6</code>，就是移动<code>master</code>、<code>HEAD</code>的“指针”地址。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092126275.png" alt="image-20230409212648050" style="zoom:67%;"><h4 id="reset模式" tabindex="-1">reset模式 <a class="header-anchor" href="#reset模式" aria-label="Permalink to &quot;reset模式&quot;">​</a></h4><p><code>reset</code>有三种模式，对应三种参数：<code>mixed</code>（默认模式）、<code>soft</code>、<code>hard</code>。三种参数的主要区别就是对工作区、暂存区的操作不同。<code>mixed</code>为默认模式，参数可以省略。只有<code>hard</code>模式会重置工作区、暂存区，一般用这个模式多</p><table><thead><tr><th style="text-align:left;"><strong>模式名称</strong></th><th style="text-align:left;"><strong>描述</strong></th><th style="text-align:left;"><strong>HEAD的位置</strong></th><th style="text-align:left;"><strong>暂存区</strong></th><th style="text-align:left;"><strong>工作区</strong></th></tr></thead><tbody><tr><td style="text-align:left;"><strong>soft</strong></td><td style="text-align:left;">回退到某一个版本，工作区不变，需手动<code>git checkout</code></td><td style="text-align:left;">修改</td><td style="text-align:left;">不修改</td><td style="text-align:left;">不修改</td></tr><tr><td style="text-align:left;"><strong>mixed</strong>(默认)</td><td style="text-align:left;">撤销暂存区状态，不影响工作区，需手动<code>git checkout</code></td><td style="text-align:left;">修改</td><td style="text-align:left;">修改</td><td style="text-align:left;">不修改</td></tr><tr><td style="text-align:left;"><strong>hard</strong></td><td style="text-align:left;">重置未提交修改（工作区、暂存区）</td><td style="text-align:left;">修改</td><td style="text-align:left;">修改</td><td style="text-align:left;">修改</td></tr></tbody></table><p>穿梭前，用<code>git log</code>可以查看提交历史，以便确定要回退到哪个版本。要重返未来，用<code>git reflog</code>查看命令历史，以便确定要回到未来的哪个版本。</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reset</span><span style="color:#A6ACCD;"> [--soft </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">--mixed</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">--hard]</span><span style="color:#A6ACCD;"> [HEAD]</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 撤销暂存区</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reset</span></span>
<span class="line"><span style="color:#FFCB6B;">Unstaged</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">changes</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">after</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reset:</span></span>
<span class="line"><span style="color:#FFCB6B;">M</span><span style="color:#A6ACCD;">       </span><span style="color:#C3E88D;">R.md</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 撤销工作区、暂存区修改</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reset</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--hard</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HEAD</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 回退版本库到上一个版本，并重置工作区、暂存</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reset</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--hard</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HEAD~</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 回到原来的版本（恢复上一步的撤销操作），并重置工作区、暂存</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reset</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--hard</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">5</span><span style="color:#C3E88D;">f8b961</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 查看所有历史提交记录</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reflog</span></span>
<span class="line"><span style="color:#FFCB6B;">ccb9937</span><span style="color:#A6ACCD;"> (HEAD -</span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">main,</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin/main,</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin/HEAD</span><span style="color:#A6ACCD;">) HEAD@{</span><span style="color:#FFCB6B;">0}:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">报表新增导入功能</span></span>
<span class="line"><span style="color:#FFCB6B;">8f61a60</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HEAD@{</span><span style="color:#F78C6C;">1</span><span style="color:#C3E88D;">}:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">bug：修复报表导出bug</span></span>
<span class="line"><span style="color:#FFCB6B;">4869ff7</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HEAD@{</span><span style="color:#F78C6C;">2</span><span style="color:#C3E88D;">}:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">用户报表模块开发</span></span>
<span class="line"><span style="color:#FFCB6B;">4b1028c</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HEAD@{</span><span style="color:#F78C6C;">3</span><span style="color:#C3E88D;">}:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit:</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">财务报表模块开发完成</span></span></code></pre></div><h4 id="实战演练" tabindex="-1">实战演练 <a class="header-anchor" href="#实战演练" aria-label="Permalink to &quot;实战演练&quot;">​</a></h4><p>查看版本库信息</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--oneline</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072142268.png" alt="image-20230407214237135" style="zoom:80%;"><p>将版本库文件重置到某一个版本，可行，会丢失提交过程</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 这里的f2f113f就是版本Hash值，用于唯一确定版本库中此版本的标记</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 当然了这是一个简短版，完整的比较长</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 如果不记得具体的版本值，版本值也可以使用HEAD值，比如最新的上一个版本：HEAD^</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 如果后退更多的版本,可以使用 HEAD~N</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reset</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--hard</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">f2f113f</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072143458.png" alt="image-20230407214318325" style="zoom:80%;"><p>被删除的文件回来了</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072143620.png" alt="image-20230407214328499" style="zoom:80%;"><p>将版本库文件重置到某一个版本，可行，不会丢失提交过程，相当于一次新的提交</p><h3 id="git-checkout" tabindex="-1">git checkout <a class="header-anchor" href="#git-checkout" aria-label="Permalink to &quot;git checkout&quot;">​</a></h3><p>如果文件还在<strong>工作区</strong>，还没添加到暂存区，可以使用git checkout撤销</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 丢弃某个文件file</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> [file] </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 只撤销工作区的修改（未暂存）</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">.</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 撤销工作区、暂存区的修改</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">HEAD</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">.</span></span></code></pre></div><p>以下demo，使用git checkout -- test.txt 撤销了test.txt的修改</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">test.txt</span></span></code></pre></div><p>代码已经推送到远程服务器了，我想撤回某个文件，你可以这么操作：</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 查看文件历史版本</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#C3E88D;">filenam</span><span style="color:#A6ACCD;">e</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 回滚到指定commitId</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#C3E88D;">commitI</span><span style="color:#A6ACCD;">d</span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#C3E88D;">filenam</span><span style="color:#A6ACCD;">e</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 提交被修改的文件</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-m</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">回滚特定文件的变动</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 推送</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span></span></code></pre></div><h3 id="git-revert" tabindex="-1">git revert <a class="header-anchor" href="#git-revert" aria-label="Permalink to &quot;git revert&quot;">​</a></h3><blockquote><p>安全的撤销某一个提交记录，基本原理就是生产一个新的提交，用原提交的逆向操作来完成撤销操作。注意，这不同于<code>reset</code>，<code>reset</code>是回退版本，revert只是用于撤销某一次历史提交，操作是比较安全的。</p></blockquote><blockquote><p>应用场景：有一天测试突然跟你说，你开发上线的功能有问题，需要马上撤回，否则会影响到系统使用。这时可能会想到用 reset 回退，可是你看了看分支上最新的提交还有其他同事的代码，用 reset 会把这部分代码也撤回了。由于情况紧急，又想不到好方法，还是任性的使用 reset，然后再让同事把他的代码合一遍（同事听到想打人），于是你的技术形象在同事眼里一落千丈。</p></blockquote><h4 id="图解分析" tabindex="-1">图解分析 <a class="header-anchor" href="#图解分析" aria-label="Permalink to &quot;图解分析&quot;">​</a></h4><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092137638.png" alt="image-20230409213757395" style="zoom:80%;"><ul><li>想撤销<code>v4</code>的修改，执行<code>git revert v4</code>，会产生一个新的提交<code>v-4</code>，是<code>v4</code>的逆向操作。</li><li>同时更新<code>matser</code>、<code>HEAD</code>“指针”位置，以及工作区内容。</li><li>如果已<code>push</code>则重新<code>push</code>即可。</li></ul><h4 id="实战演练-1" tabindex="-1">实战演练 <a class="header-anchor" href="#实战演练-1" aria-label="Permalink to &quot;实战演练&quot;">​</a></h4><blockquote><p>源文件夹包含如下4个文件，此时我删除qwe.txt，并进行提交，注意是撤销提交</p></blockquote><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reflog</span><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;"># 得到你需要回退一次提交的commit id</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">revert</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-n</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#C3E88D;">commit_i</span><span style="color:#A6ACCD;">d</span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;"># 撤销指定的版本，撤销也会作为一次提交进行保存,66522bd</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.6.30/202207231852473.png" alt="image-20220723185253350" style="zoom:50%;"><h2 id="分支分类" tabindex="-1">分支分类 <a class="header-anchor" href="#分支分类" aria-label="Permalink to &quot;分支分类&quot;">​</a></h2><h3 id="主分支master" tabindex="-1">主分支Master <a class="header-anchor" href="#主分支master" aria-label="Permalink to &quot;主分支Master&quot;">​</a></h3><p>首先，代码库应该有一个、且仅有一个主分支。所有提供给用户使用的正式版本，都在这个主分支上发布。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092036640.png" alt="image-20230409203611496" style="zoom:80%;"><p>Git主分支的名字，默认叫做Master。它是自动建立的，版本库初始化以后，默认就是在主分支在进行开发。</p><h3 id="开发分支develop" tabindex="-1">开发分支Develop <a class="header-anchor" href="#开发分支develop" aria-label="Permalink to &quot;开发分支Develop&quot;">​</a></h3><p>主分支只用来发布重大版本，日常开发应该在另一条分支上完成。我们把开发用的分支，叫做Develop。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092036811.png" alt="image-20230409203623659" style="zoom:80%;"><p>这个分支可以用来生成代码的最新隔夜版本（nightly）。如果想正式对外发布，就在Master分支上，对Develop分支进行&quot;合并&quot;（merge）。</p><p>Git创建Develop分支的命令：</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-b</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">develop</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span></span></code></pre></div><p>将Develop分支发布到Master分支的命令：</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 切换到Master分支</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 对Develop分支进行合并</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">merge</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--no-ff</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">develop</span></span></code></pre></div><p>这里稍微解释一下上一条命令的--no-ff参数是什么意思。默认情况下，Git执行&quot;快进式合并&quot;（fast-farward merge），会直接将Master分支指向Develop分支。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092036294.png" alt="image-20230409203649125" style="zoom:67%;"><p>使用--no-ff参数后，会执行正常合并，在Master分支上生成一个新节点。为了保证版本演进的清晰，我们希望采用这种做法。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092037264.png" alt="image-20230409203705117" style="zoom:67%;"><h3 id="临时性分支" tabindex="-1">临时性分支 <a class="header-anchor" href="#临时性分支" aria-label="Permalink to &quot;临时性分支&quot;">​</a></h3><p>前面讲到版本库的两条主要分支：Master和Develop。前者用于正式发布，后者用于日常开发。其实，常设分支只需要这两条就够了，不需要其他了。</p><p>但是，除了常设分支以外，还有一些临时性分支，用于应对一些特定目的的版本开发。临时性分支主要有三种：</p><ul><li>功能（feature）分支</li><li>预发布（release）分支</li><li>修补bug（fixbug）分支</li></ul><p>这三种分支都属于临时性需要，使用完以后，应该删除，使得代码库的常设分支始终只有Master和Develop。</p><p>接下来，一个个来看这三种&quot;临时性分支&quot;。</p><p><strong>第一种是功能分支</strong>，它是为了开发某种特定功能，从Develop分支上面分出来的。开发完成后，要再并入Develop。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092037772.png" alt="image-20230409203716622" style="zoom:67%;"><p>功能分支的名字，可以采用feature-*的形式命名。</p><p>创建一个功能分支：</p><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git checkout -b feature-x develop</span></span></code></pre></div><p>开发完成后，将功能分支合并到develop分支：</p><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git checkout develop</span></span>
<span class="line"><span style="color:#A6ACCD;"></span></span>
<span class="line"><span style="color:#A6ACCD;">git merge --no-ff feature-x</span></span></code></pre></div><p>删除feature分支：</p><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git branch -d feature-x</span></span></code></pre></div><p><strong>第二种是预发布分支</strong>，它是指发布正式版本之前（即合并到Master分支之前），我们可能需要有一个预发布的版本进行测试。预发布分支是从Develop分支上面分出来的，预发布结束以后，必须合并进Develop和Master分支。它的命名，可以采用release-*的形式。</p><p>创建一个预发布分支：</p><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git checkout -b release-1.2 develop</span></span></code></pre></div><p>确认没有问题后，合并到master分支：</p><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git checkout master</span></span>
<span class="line"><span style="color:#A6ACCD;">git merge --no-ff release-1.2</span></span>
<span class="line"><span style="color:#A6ACCD;"># 对合并生成的新节点，做一个标签</span></span>
<span class="line"><span style="color:#A6ACCD;">git tag -a 1.2</span></span></code></pre></div><p>再合并到develop分支：</p><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git checkout develop</span></span>
<span class="line"><span style="color:#A6ACCD;">git merge --no-ff release-1.2</span></span></code></pre></div><p>最后，删除预发布分支：</p><div class="language-"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git branch -d release-1.2</span></span></code></pre></div><p><strong>最后一种是修补bug分支</strong>。软件正式发布以后，难免会出现bug。这时就需要创建一个分支，进行bug修补。</p><p>修补bug分支是从Master分支上面分出来的。修补结束以后，再合并进Master和Develop分支。它的命名，可以采用fixbug-*的形式。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092037004.png" alt="image-20230409203730853" style="zoom:67%;"><p>创建一个修补bug分支：</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-b</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">fixbug-0.1</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span></span></code></pre></div><p>修补结束后，合并到master分支：</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">merge</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--no-ff</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">fixbug-0.1</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">tag</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-a</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">0.1</span><span style="color:#C3E88D;">.1</span></span></code></pre></div><p>再合并到develop分支：</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">develop</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">merge</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--no-ff</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">fixbug-0.1</span></span></code></pre></div><p>最后，删除&quot;修补bug分支&quot;：</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">branch</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">fixbug-0.1</span></span></code></pre></div><h2 id="分支操作" tabindex="-1">分支操作 <a class="header-anchor" href="#分支操作" aria-label="Permalink to &quot;分支操作&quot;">​</a></h2><blockquote><p>在之前的操作中，所有的操作都是基于一条主线完成的。就好比，咱们学习的时候，记学习笔记，今天学点，那么就写一点，明天学点，再写一点，最后，完全学完了，这个笔记也就记全了。但实际上，有些文件可能再不同的场合需要同时使用不同的内容，而且还不能冲突，比如项目的配置文件，我需要本地进行测试，同时还要部署到服务器上进行测试。本地和服务器上的环境是不一样的，所以同一个配置文件就需要根据环境的不同，进行不同的修改。本地环境没问题了，修改配置文件，提交到服务器上进行测试，如果测试有问题，再修改为本地环境，重新测试，没问题了，再修改为服务器配置，然后提交到服务器上进行测试。依次类推，形成迭代式开发测试。</p></blockquote><blockquote><p>从上面的描述上看，就会显得非常繁琐，而且本质上并没有太重要的内容，仅仅是因为环境上的变化，就需要重新修改，所以如果将本地测试环境和服务器测试环境区分开，分别进行文件版本维护，是不是就会显得更合理一些。这个操作，在Git软件中，我们称之为branch，分支。</p></blockquote><blockquote><p>这里的分支感觉上就是树上的分叉一样，会按照不同的路线生长下去。有可能以后不再相交，当然，也可能以后会不断地纠缠下去，都是有可能的。</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072143901.png" alt="image-20230407214359751" style="zoom:80%;"><table><thead><tr><th style="text-align:left;"><strong>指令</strong></th><th style="text-align:left;"><strong>描述</strong></th></tr></thead><tbody><tr><td style="text-align:left;">git branch</td><td style="text-align:left;">列出所有本地分支，加参数<code>-v</code>显示详细列表，下同</td></tr><tr><td style="text-align:left;">git branch -r</td><td style="text-align:left;">列出所有远程分支</td></tr><tr><td style="text-align:left;">git branch -a</td><td style="text-align:left;">列出所有本地分支和远程分支，用不同颜色区分</td></tr><tr><td style="text-align:left;">git branch [branch-name]</td><td style="text-align:left;">新建一个分支，但依然停留在当前分支</td></tr><tr><td style="text-align:left;">git branch -d dev</td><td style="text-align:left;">删除<code>dev</code>分支，-D（大写）强制删除</td></tr><tr><td style="text-align:left;"><strong>git checkout -b</strong> dev</td><td style="text-align:left;">从当前分支创建并切换到<code>dev</code>分支</td></tr><tr><td style="text-align:left;">git checkout <strong>-b</strong> feature1 dev</td><td style="text-align:left;">从本地<code>dev</code>分支代码创建一个 <code>feature1</code>分支，并切换到新分支</td></tr><tr><td style="text-align:left;">git branch [branch] [commit]</td><td style="text-align:left;">新建一个分支，指向指定<code>commit id</code></td></tr><tr><td style="text-align:left;">git branch --track [branch] [remote-branch]</td><td style="text-align:left;">新建一个分支，与指定的远程分支建立关联</td></tr><tr><td style="text-align:left;">git checkout -b hotfix remote hotfix</td><td style="text-align:left;">从远端<code>remote</code>的<code>hotfix</code>分支创建本地<code>hotfix</code>分支</td></tr><tr><td style="text-align:left;">git branch --set-upstream [branch] [remote-branch]</td><td style="text-align:left;">在现有分支与指定的远程分支之间建立跟踪关联：<code>git branch --set-upstream hotfix remote/hotfix</code></td></tr><tr><td style="text-align:left;"><strong>git checkout</strong> [branch-name]</td><td style="text-align:left;">切换到指定分支，并更新工作区</td></tr><tr><td style="text-align:left;">git checkout .</td><td style="text-align:left;">撤销工作区的（未暂存）修改，把暂存区恢复到工作区。</td></tr><tr><td style="text-align:left;">git checkout HEAD .</td><td style="text-align:left;">撤销工作区、暂存区的修改，用<code>HEAD</code>指向的当前分支最新版本替换</td></tr><tr><td style="text-align:left;">git merge [branch]</td><td style="text-align:left;">合并指定分支到当前分支</td></tr><tr><td style="text-align:left;"><strong>git merge --no-ff</strong> dev</td><td style="text-align:left;">合并<code>dev</code>分支到当前分支，参数<code>--no-ff</code>禁用快速合并模式</td></tr><tr><td style="text-align:left;">git push origin --delete [branch-name]</td><td style="text-align:left;">删除远程分支</td></tr><tr><td style="text-align:left;">git rebase master</td><td style="text-align:left;">将当前分支变基合并到<code>master</code>分支</td></tr><tr><td style="text-align:left;">✅switch：新的分支切换指令</td><td style="text-align:left;">切换功能和<code>checkout</code>一样，<code>switch</code>只单纯的用于切换</td></tr><tr><td style="text-align:left;">git switch master</td><td style="text-align:left;">切换到已有的<code>master</code>分支</td></tr><tr><td style="text-align:left;">git switch -c dev</td><td style="text-align:left;">创建并切换到新的<code>dev</code>分支</td></tr></tbody></table><h3 id="主干分支" tabindex="-1">主干分支 <a class="header-anchor" href="#主干分支" aria-label="Permalink to &quot;主干分支&quot;">​</a></h3><blockquote><p>默认情况下，Git软件就存在分支的概念，而且就是一个分支，称之为master分支，也称之为主干分支。</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072144258.png" alt="image-20230407214413142" style="zoom:80%;"><p>这就意味着，所有文件的版本管理操作都是在master这一个分支路线上进行完成的。</p><blockquote><p>不过奇怪的是，为什么之前的操作没有体现这个概念呢，那是因为，默认的所有操作本身就都是基于master分支完成的。而master主干分支在创建版本库时，也就是git init时默认就会创建。就像之前说的，如果仅仅是一个分支，在某些情况并不能满足实际的需求，那么就需要创建多个不同的分支。</p></blockquote><h3 id="创建分支" tabindex="-1">创建分支 <a class="header-anchor" href="#创建分支" aria-label="Permalink to &quot;创建分支&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 新建一个分支，但是仍停留在原来分支</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">branch</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">b1</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">branch</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">b2</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 新建一个分支，并且切换到新的分支dev2</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-b</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">dev2</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072144877.png" alt="image-20230407214442745" style="zoom:80%;"><p>现在我们创建了2个分支，不过这两个分支都是基于master主干分支为基础的。</p><h3 id="查看分支" tabindex="-1">查看分支 <a class="header-anchor" href="#查看分支" aria-label="Permalink to &quot;查看分支&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092108957.png" alt="image-20230409210809723" style="zoom:50%;"><p>类似于<code>ls</code>，能够列出当前所有分支。<code>git branch -v</code> 能够显示更多信息。</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git branch</span></span></code></pre></div><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git branch    </span><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> 查看本地所有的分支</span></span>
<span class="line"><span style="color:#A6ACCD;">git branch </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">v </span><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> 能够显示更多信息</span></span>
<span class="line"><span style="color:#A6ACCD;">git branch </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">r  </span><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> 查看所有远程的分支</span></span>
<span class="line"><span style="color:#A6ACCD;">git branch </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">a  </span><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> 查看所有远程分支和本地分支</span></span>
<span class="line"><span style="color:#A6ACCD;">git checkout </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> 跳到之前的分支</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072144761.png" alt="image-20230407214454640" style="zoom:80%;"><h3 id="切换分支" tabindex="-1">切换分支 <a class="header-anchor" href="#切换分支" aria-label="Permalink to &quot;切换分支&quot;">​</a></h3><p>代码仓库可以有多个分支，<code>master</code>为默认的主分支，但只有一个分支在工作状态。所以要操作不同分支，需要切换到该分支，<code>HEAD</code>就是指向当前正在活动的分支。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092109120.png" alt="image-20230409210926915" style="zoom:67%;"><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 此处 switch 作用同 checkout，switch只用于切换，不像checkout功能很多</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">switch</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">dev</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 检出一个版本库，默认将更新到master分支</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 检出到一个特定的分支</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">branchName</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 新建一个分支，并且切换过去，相当于&quot;git branch &lt;名字&gt;; git checkout &lt;名字&gt;&quot;</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-b</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">newBranch</span></span></code></pre></div><p>使用 <code>git checkout dev</code>切换分支时，干了两件事：</p><p>①、<code>HEAD</code>指向<code>dev</code>：修改<code>HEAD</code>的“指针”引用，指向<code>dev</code>分支。</p><p>②、还原工作空间：把<code>dev</code>分支内容还原到工作空间。</p><p>此时的活动分支就是<code>dev</code>了，后续的提交就会更新到<code>dev</code>分支了。</p><p>**❓切换时还没提交的代码怎么办？**如果修改（包括未暂存、已暂存）和待切换的分支没有冲突，则切换成果，且未提交修改会一起带过去，所以要注意！如果有冲突，则会报错，提示先提交或隐藏，关于隐藏可查看后续章节内容“stash”</p><p>此时我们添加新的文件b1.txt</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072145225.png" alt="image-20230407214533106" style="zoom:80%;"><p>然后提交到版本库</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072145879.png" alt="image-20230407214545739" style="zoom:80%;"><p>此时，查看分支信息，会发现不同分支的版本进度信息发生了改变</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072145444.png" alt="image-20230407214558315" style="zoom:80%;"><p>如果此时切换回到主干分支的话，那么b1.txt文件就不存在了，因为对应版本信息不一样。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072146310.png" alt="image-20230407214612179" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072146824.png" alt="image-20230407214624684" style="zoom:80%;"><h3 id="删除分支" tabindex="-1">删除分支 <a class="header-anchor" href="#删除分支" aria-label="Permalink to &quot;删除分支&quot;">​</a></h3><p>如果觉得某一个分支建立的不太理想或已经没有必要在使用了，那么是可以将这个分支删除的。不能删除当前分支，只能删除其他分支，强制删除使用场景：用-d删除不了，出现提示问题，就用-D</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git branch </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">d b1 </span><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> 删除分支时，需要做各种检查。</span></span>
<span class="line"><span style="color:#A6ACCD;">git branch </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">D b1 </span><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> 不做任何检查，强制删除。</span></span></code></pre></div><h3 id="创建并切换分支" tabindex="-1">创建并切换分支 <a class="header-anchor" href="#创建并切换分支" aria-label="Permalink to &quot;创建并切换分支&quot;">​</a></h3><p>我们还可以直接切换到一个不存在的分支（创建并切换）⭐⭐克隆完之后呢，开发新需求的话，我们需要新建一个开发分支，比如新建开发分支dev</p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git checkout </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">b dev   </span><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> 创建开发分支dev，并切换到该分支下</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img/image-20210930181935431.png" alt="image-20210930181935431" style="zoom:80%;"><h3 id="推送分支" tabindex="-1">推送分支 <a class="header-anchor" href="#推送分支" aria-label="Permalink to &quot;推送分支&quot;">​</a></h3><p>推送至远程仓库分支命令格式：git push 远程仓库简称 分支命令，查看远程仓库简称(一般都是origin)</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">remote</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-v</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211022147648.png" alt="image-20221102214729557" style="zoom:80%;"><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 推送分支至远程</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">b1</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">b2</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 分支推送内容，必须加上-u参数</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-u</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">b1</span></span></code></pre></div><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 实战实例</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-b</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">b1</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 新增修改了文件</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">.</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-m</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">b1分支更新</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-u</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">b1</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211022148085.png" alt="image-20221102214820006" style="zoom:80%;"><p>推送完成后可以查看远程仓库：</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211022148191.png" alt="image-20221102214853116" style="zoom:80%;"><h3 id="清理分支" tabindex="-1">清理分支 <a class="header-anchor" href="#清理分支" aria-label="Permalink to &quot;清理分支&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 移除远程仓库上不存在的分支</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">fetch</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 移除所有包含 `greenkeeper` 的分支</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">fetch</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-p</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&amp;&amp;</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">branch</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--remote</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">fgrep</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">greenkeeper</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">sed</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">s/^.\{9\}//</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">xargs</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--delete</span></span></code></pre></div><h3 id="分支命名规则" tabindex="-1">分支命名规则 <a class="header-anchor" href="#分支命名规则" aria-label="Permalink to &quot;分支命名规则&quot;">​</a></h3><p>几乎所有的版本控制系统都以某种形式支持分支。 使用分支意味着你可以把你的工作从开发主线上分离开来进行重大的Bug修改、开发新的功能，以免影响开发主线。在开发中，一般有如下分支使用原则与流程：还有一些其他分支，在此不再详述，例如test分支（用于代码测试）、pre分支（预上线分支）等。</p><blockquote><p>master （生产） 线上分支，主分支，中小规模项目作为线上运行的应用对应的分支</p><p>develop（开发）是从master创建的分支，一般作为开发部门的主要开发分支，如果没有其他并行开发不同期上线。要求，都可以在此版本进行开发，阶段开发完成后，需要是合并到master分支,准备上线</p><p>feature/xxxx 从develop创建的分支，一般是同期并行开发，但不同期上线时创建的分支，分支上的研发任务完 成后合并到develop分支。</p><p>hotfix/xxxx 从master派生的分支，一般作为线上bug修复使用，修复完成后需要合并到master、test、 develop分支。</p></blockquote><h2 id="合并分支" tabindex="-1">合并分支 <a class="header-anchor" href="#合并分支" aria-label="Permalink to &quot;合并分支&quot;">​</a></h2><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072147133.png" alt="image-20230407214751009" style="zoom:80%;"><p>合并就是将外部的提交合并到自己的分支中</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 将其他分支合并到当前分支</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">merge</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">branchName</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 在合并时创建一个新的合并后的提交</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 不要 Fast-Foward 合并，这样可以生成 merge 提交</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">merge</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--no-ff</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">branchName</span></span></code></pre></div><h3 id="主干分支-1" tabindex="-1">主干分支 <a class="header-anchor" href="#主干分支-1" aria-label="Permalink to &quot;主干分支&quot;">​</a></h3><p>首先我们先将主干分支的所有文件清空掉</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072148820.png" alt="image-20230407214804687" style="zoom:80%;"><p>在当前主干分支中创建一份文件master.txt，并提交</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072148902.png" alt="image-20230407214818752" style="zoom:80%;"><h3 id="其他分支" tabindex="-1">其他分支 <a class="header-anchor" href="#其他分支" aria-label="Permalink to &quot;其他分支&quot;">​</a></h3><p>基于主干分支的内容，我们创建其他分支，并直接切换到新的分支</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># git checkout -b 分支名称</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-b</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">new_branch</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072148529.png" alt="image-20230407214844395" style="zoom:80%;"><p>在新的分支中添加新文件branch.txt</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072148453.png" alt="image-20230407214855309" style="zoom:80%;"><p>此时切换回主干分支，只有master.txt文件。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072149230.png" alt="image-20230407214908033" style="zoom:80%;"><p>再切换回new_branch分支，branch文件就又回来了。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072149897.png" alt="image-20230407214920750" style="zoom:80%;"><h3 id="合并分支⭐" tabindex="-1">合并分支⭐ <a class="header-anchor" href="#合并分支⭐" aria-label="Permalink to &quot;合并分支⭐&quot;">​</a></h3><p>两种方式：<code>merge</code> 是将分支合并成一个新的节点，保留分支独立性，而 <code>rebase</code> 是将分支合并到目标分支的顶部，形成线性提交记录，但会丢失分支独立性。</p><blockquote><p><code>merge</code>：将两个或多个分支的历史记录合并为一个新的提交，并将新的提交作为一个新的节点添加到当前分支的提交历史中。这种合并方式会保留每个分支的提交历史，并保持分支之间的独立性，适合于多人协作开发场景。合并后的历史记录会形成一个合并节点，表示分支之间的合并关系。合并时会产生一个新的提交，包含合并后的代码和提交信息。</p></blockquote><blockquote><p><code>rebase</code>：将当前分支的基础（base）更改为另一个分支的最新提交，然后将当前分支的新提交放置在目标分支的顶部。这种合并方式会修改提交历史记录，并且会丢失原有分支的独立性，适合于个人开发场景。合并后的历史记录会保持线性，没有合并节点，看起来更加干净整洁。合并时会修改提交的提交信息，不会产生新的提交。</p></blockquote><p>这里我们将b1分支的文件内容合并到主干分支中。首先先切换回主干分支，然后执行分支合并指令</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">merge</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">b1</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span></span></code></pre></div><p>rebase 的作用更多的是来整合分叉的历史，可以将某个分支上的所有修改都移到另一分支上，就像是变了基底</p><p>与 merge 会保留修改内容的历史记录不同，rebase 是在原有提交的基础上将差异内容反映进去。git rebase会复制当前分支的所有提交，并移动当前分支到要合并分支的最新提交上，并<strong>改变当前分支所有提交的hash值（C3&#39;）</strong>。</p><p><code>rebase</code>也是一种合并指令，命令行如下：git rebase 分支名</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-b</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">b2</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">.</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-m</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">新增文件</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-u</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">b2</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rebase</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">b2</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--force</span></span></code></pre></div><p>与<code>merge</code>不同的是<code>rebase</code>合并看起来不会产生新的节点(实际上是会产生的，只是做了一次复制)，而是将需要合并的节点直接累加，如图</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.6.30/202207241013346.png" alt="image-20220724101359242" style="zoom:67%;"><img src="https://mmbiz.qpic.cn/mmbiz_gif/rENF8sGwVPcrayWb96TqpmzcMPsr4wvQRmhggHkAZgLTibhjR4sCA4DIAiaBkWjUIv9S82o8gGST5QnpZPk0jbZw/640?wx_fmt=gif&amp;wxfrom=5&amp;wx_lazy=1" alt="图片" style="zoom:67%;"><p>其实git rebase 和git merge 做的事是一样的。它们都被设计用来将一个分支的更改并入另一个分支，方式有些不同</p><p><strong>merge:</strong></p><ul><li>优点：分支合并后，原分支会保留，较为安全，操作简单</li><li>缺点：会引入一次不必要的commit，如果团队庞大，提交树会变得杂乱无章</li></ul><p><strong>rebase:</strong></p><ul><li>优点：rebase会使项目提交树很干净，所有的提交都在一条线上</li><li>缺点：rebase后会改变commit的hash值，改变了提交树的历史</li></ul><h3 id="合并方式" tabindex="-1">合并方式 <a class="header-anchor" href="#合并方式" aria-label="Permalink to &quot;合并方式&quot;">​</a></h3><blockquote><p>把两个分支的修改内容合并到一起，常用的合并指令<code>git merge [branch]</code>，将分支<code>[branch]</code>合并到当前分支。根据要合并的内容的不同，具体合并过程就会有多种情况。</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092113339.png" alt="image-20230409211338142" style="zoom:80%;"><h4 id="快速合并-fast-forward" tabindex="-1">快速合并（Fast forward） <a class="header-anchor" href="#快速合并-fast-forward" aria-label="Permalink to &quot;快速合并（Fast forward）&quot;">​</a></h4><p>如下图，<code>master</code>分支么有任何提交，“<code>git merge dev</code>”合并分支<code>dev</code>到<code>master</code>，此时合并速度就非常快，直接移动<code>master</code>的“指针”引用到<code>dev</code>即可。这就是快速合并（Fast forward），不会产生新的提交。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092116415.png" alt="image-20230409211633211" style="zoom:80%;"><ul><li>合并<code>dev</code>到<code>master</code>，注意要先切换到<code>master</code>分支，然后执行<code>git merge dev</code>，把<code>dev</code>合并到当前分支。</li></ul><blockquote><p><strong>📢强制不用快速合并</strong>：<code>git merge --no-ff -m &quot;merge with no-ff&quot; dev</code>，参数<code>--no-ff</code>不启用快速合并，会产生一个新的合并提交记录。</p></blockquote><h4 id="普通合并" tabindex="-1">普通合并 <a class="header-anchor" href="#普通合并" aria-label="Permalink to &quot;普通合并&quot;">​</a></h4><p>如果<code>master</code>有变更，存在分支交叉，则会把两边的变更合并成一个提交。</p><ul><li>如果两边变更的文件不同，没有什么冲突，就自动合并了。</li><li>如果有修改同一个文件，则会存在冲突，到底该采用哪边的，程序无法判断，就换产生冲突。冲突内容需要人工修改后再重新提交，才能完成最终的合并。</li></ul><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092116517.png" alt="image-20230409211622308" style="zoom:80%;"><p>上图中，创建<code>dev</code>分支后，两个分支都有修改提交，因此两个分支就不在一条顺序线上了，此时合并<code>dev</code>到<code>master</code>就得把他们的修改进行合并操作了。</p><ul><li><code>v5</code>、<code>v7</code>共同祖先是<code>v4</code>，从这里开始分叉。</li><li>Git 会用两个分支的末端<code>v6</code> 和 <code>v8</code>以及它们的共同祖先<code>v4</code>进行三方合并计算。合并之后会生成一个新（和并）提交<code>v9</code>。</li><li>合并提交<code>v9</code>就有两个祖先<code>v6</code>、<code>v8</code>。</li></ul><h4 id="处理冲突-head" tabindex="-1">处理冲突&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD <a class="header-anchor" href="#处理冲突-head" aria-label="Permalink to &quot;处理冲突&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD&quot;">​</a></h4><p>在有冲突的文件中，<code>&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD</code>开头的内容就表示是有冲突的部分，需要人工处理，可以借助一些第三方的对比工具。人工处理完毕后，完成合并提交，才最终完成此次合并。<code>=======</code>分割线上方是当前分支的内容，下方是被合并分支的变更内容。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092115797.png" alt="image-20230409211524600" style="zoom:80%;"><h4 id="变基rebase" tabindex="-1">变基rebase <a class="header-anchor" href="#变基rebase" aria-label="Permalink to &quot;变基rebase&quot;">​</a></h4><p>把两个分支的修改内容合并到一起的办法有两种：<code>merge</code> 和 <code>rebase</code>，作用都是一样的，区别是<code>rebase</code>的提交历史更简洁，干掉了分叉，merge的提交历史更完整。</p><p><img src="https://mmbiz.qpic.cn/mmbiz_png/A3ibcic1Xe0iaQlYph2qibic0ib3NzFAiciafWKwrr7g2iam9CeIibLB0uET8aLhHCgoYWLtqwfXDUeuYzxHohl7csSp6ZYQ/640?wx_fmt=png&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="图片"></p><ul><li>在<code>dev</code>上执行“<code>git rebase master</code>”变基，将<code>dev</code>分支上分叉的<code>v7</code>、<code>v8</code>生成补丁，然后在<code>master</code>分支上应用补丁，产生新的<code>v7&#39;</code>、<code>v8&#39;</code>新的提交。</li><li>然后回到<code>master</code>分支，完成合并<code>git merge dev</code>，此时的合并就是快速合并了。</li><li>最终的提交记录就没有分叉了。</li></ul><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rebase</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">merge</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">dev</span></span></code></pre></div><h2 id="冲突分支" tabindex="-1">冲突分支 <a class="header-anchor" href="#冲突分支" aria-label="Permalink to &quot;冲突分支&quot;">​</a></h2><img src="https://mmbiz.qpic.cn/mmbiz_gif/rENF8sGwVPcrayWb96TqpmzcMPsr4wvQYvFTHUUsicI3O4wHWs2ABRW5O9sJrpnqgB3V6hHgYdiaNsWhYpybQN3w/640?wx_fmt=gif&amp;wxfrom=5&amp;wx_lazy=1" alt="图片" style="zoom:67%;"><h3 id="合并冲突" tabindex="-1">合并冲突 <a class="header-anchor" href="#合并冲突" aria-label="Permalink to &quot;合并冲突&quot;">​</a></h3><p>在一段时间，A、B用户修改了同一个文件，且修改了同一行位置的代码，此时会发生合并冲突。A用户在本地修改代码后优先推送到远程仓库，此时B用户在本地修订代码，提交到本地仓库后，也需要推送到远程仓库，此时B用户晚于A用户，故需要先拉取远程仓库的提交，经过合并后才能推送到远端分支,如下图所示。 <img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img/image-20210930191432346.png" alt="image-20210930191432346" style="zoom:80%;"></p><p>在B用户拉取代码时，因为A、B用户同一段时间修改了同一个文件的相同位置代码，故会发生合并冲突。远程分支也是分支，所以合并时冲突的解决方式也和解决本地分支冲突相同相同。Git版本控制，是多个人一起搞的，多个分支并存的，这就难免会有冲突出现~</p><p>同一个文件，在合并分支的时候，如果同一行被多个分支或者不同人都修改了，合并的时候就会出现冲突。</p><p>举个粟子吧，我们现在在master分支，修改HelloWorld.java文件，进行提交</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211022200785.png" alt="image-20221102220043699" style="zoom:80%;"><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">.</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-m</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">在master修改内容</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span></span></code></pre></div><p>我们切回到b1分支，也修改HelloWorld.java同一位置内容，如下：</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211022202066.png" alt="image-20221102220225985" style="zoom:80%;"><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">.</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-m</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">在b1分支修改内容</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-u</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">b1</span></span></code></pre></div><p>再然后呢，我们合并分支。就出现冲突啦，如图所示：</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">merge</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">b1</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211022206177.png" alt="image-20221102220601102" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072150958.png" alt="image-20230407215031821" style="zoom:67%;"><p>接下来，咱们就演示一下。</p><h3 id="主干分支-2" tabindex="-1">主干分支 <a class="header-anchor" href="#主干分支-2" aria-label="Permalink to &quot;主干分支&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072150484.png" alt="image-20230407215042367" style="zoom:80%;"><p>首先我们先将主干分支的所有文件清空掉</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072150696.png" alt="image-20230407215054573" style="zoom:80%;"><p>主干分支添加文件test.txt，文件内容为空</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072151277.png" alt="image-20230407215105158" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072151388.png" alt="image-20230407215115247" style="zoom:80%;"><h3 id="其他分支-1" tabindex="-1">其他分支 <a class="header-anchor" href="#其他分支-1" aria-label="Permalink to &quot;其他分支&quot;">​</a></h3><p>基于主干分支，创建两个分支B1, B2</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072151707.png" alt="image-20230407215133584" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072151846.png" alt="image-20230407215147712" style="zoom:80%;"><h3 id="切换分支-b1" tabindex="-1">切换分支-B1 <a class="header-anchor" href="#切换分支-b1" aria-label="Permalink to &quot;切换分支-B1&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072152386.png" alt="image-20230407215207259" style="zoom:67%;"><p>切换到B1分支，修改文件内容</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072152769.png" alt="image-20230407215223642" style="zoom:80%;"><p>提交修改后的文件</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072152247.png" alt="image-20230407215237114" style="zoom:80%;"><h3 id="切换分支-b2" tabindex="-1">切换分支-B2 <a class="header-anchor" href="#切换分支-b2" aria-label="Permalink to &quot;切换分支-B2&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072152920.png" alt="image-20230407215256756" style="zoom:80%;"><p>切换到B2分支，查看文件内容</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072153253.png" alt="image-20230407215311124" style="zoom:80%;"><p>修改文件内容：</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072153565.png" alt="image-20230407215323428" style="zoom:80%;"><p>提交文件</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072153141.png" alt="image-20230407215334012" style="zoom:80%;"><h3 id="合并分支-b1" tabindex="-1">合并分支-B1 <a class="header-anchor" href="#合并分支-b1" aria-label="Permalink to &quot;合并分支-B1&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072153797.png" alt="image-20230407215349678" style="zoom:80%;"><p>切换到master主干分支，此时test.txt文件内容为空</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072154246.png" alt="image-20230407215400109" style="zoom:80%;"><p>将B1分支合并到主干分支中</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072154921.png" alt="image-20230407215412782" style="zoom:80%;"><h3 id="合并分支-b2" tabindex="-1">合并分支-B2 <a class="header-anchor" href="#合并分支-b2" aria-label="Permalink to &quot;合并分支-B2&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072154266.png" alt="image-20230407215428135" style="zoom:80%;"><p>因为B2分支也对文件进行了修改，所以如果此时合并B2分支,就会提示冲突</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072154288.png" alt="image-20230407215438153" style="zoom:80%;"><p>查看文件内容差异</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072154366.png" alt="image-20230407215450231" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072155182.png" alt="image-20230407215541059" style="zoom:80%;"><p>这里的冲突，软件是无法判断该如何出来处理的，所以需要人工进行判断，将冲突的文件内容进行修正。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072155517.png" alt="image-20230407215551402" style="zoom:80%;"><p>重新提交到master主干分支中。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072156284.png" alt="image-20230407215603169" style="zoom:80%;"><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">文件名称</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-i</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-m</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">注释</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072156974.png" alt="image-20230407215611850" style="zoom:80%;"><p>再查看一下Git软件的操作日志</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--graph</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072156282.png" alt="image-20230407215624132" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072156068.png" alt="image-20230407215636940" style="zoom:80%;"><h2 id="标签操作" tabindex="-1">标签操作 <a class="header-anchor" href="#标签操作" aria-label="Permalink to &quot;标签操作&quot;">​</a></h2><blockquote><p>标签是静态的概念，分支是动态的概念，标签打完之后，代码的状态就被保存下来，不会改动。而分支可以不断地推送代码，直到完成。可以理解为某一次提交（编号）的别名，常用来标记版本。所以发布时，一般都会打一个版本标签，作为该版本的快照，指向对应提交<code>commit</code>。</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092119986.png" alt="image-20230409211915772" style="zoom:80%;"><blockquote><p>打tag就是对发布的版本标注一个版本号，如果版本发布有问题，就把该版本拉取出来，修复bug，再合回去。</p><p>Git 中的标签，指的是某个分支某个特定时间点的状态。通过标签，可以很方便的切换到标记时的状态。</p><p>比较有代表性的是人们会使用这个功能来标记发布结点（v1.0 、v1.2等）。下面是mybatis-plus的标签：</p></blockquote><table><thead><tr><th style="text-align:left;"><strong>指令</strong></th><th style="text-align:left;"><strong>描述</strong></th></tr></thead><tbody><tr><td style="text-align:left;">git tag</td><td style="text-align:left;">查看标签列表</td></tr><tr><td style="text-align:left;">git tag -l &#39;a*&#39;</td><td style="text-align:left;">查看名称是“a”开头的标签列表，带查询参数</td></tr><tr><td style="text-align:left;">git show [tagname]</td><td style="text-align:left;">查看标签信息</td></tr><tr><td style="text-align:left;"><strong>git tag</strong> [tagname]</td><td style="text-align:left;">创建一个标签，默认标签是打在最新提交的commit上的</td></tr><tr><td style="text-align:left;">git tag [tagname] [commit id]</td><td style="text-align:left;">新建一个tag在指定commit上</td></tr><tr><td style="text-align:left;">git tag -a v5.1 -m&#39;v5.1版本&#39;</td><td style="text-align:left;">创建标签<code>v5.1.1039</code>，<code>-a</code>指定标签名，<code>-m</code>指定说明文字</td></tr><tr><td style="text-align:left;">git tag -d [tagname]</td><td style="text-align:left;">删除本地标签</td></tr><tr><td style="text-align:left;">git checkout v5.1.1039</td><td style="text-align:left;">切换标签，同切换分支</td></tr><tr><td style="text-align:left;">git push [remote] v5.1</td><td style="text-align:left;">推送标签，标签不会默认随代码推送推送到服务端</td></tr><tr><td style="text-align:left;">git push [remote] --tags</td><td style="text-align:left;">提交所有tag</td></tr></tbody></table><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.6.30/202207231715311.png" alt="image-20220723171541222" style="zoom:67%;"><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">tag</span><span style="color:#A6ACCD;">			        </span><span style="color:#676E95;font-style:italic;">#列出已有的标签</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">tag</span><span style="color:#A6ACCD;"> [name]			</span><span style="color:#676E95;font-style:italic;">#新建一个tag在当前commit</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> [shortName] </span><span style="color:#89DDFF;">[</span><span style="color:#A6ACCD;">name</span><span style="color:#89DDFF;">]</span><span style="color:#A6ACCD;">	</span><span style="color:#676E95;font-style:italic;">#将标签推送至远程仓库</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-b</span><span style="color:#A6ACCD;"> [branch] </span><span style="color:#89DDFF;">[</span><span style="color:#A6ACCD;">name</span><span style="color:#89DDFF;">]</span><span style="color:#A6ACCD;">	</span><span style="color:#676E95;font-style:italic;"># 检出标签</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">tag</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span><span style="color:#A6ACCD;"> [tag]      </span><span style="color:#676E95;font-style:italic;">#删除本地tag</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> [tag] </span><span style="color:#676E95;font-style:italic;">#推送tag到远程</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">show</span><span style="color:#A6ACCD;"> [tag]        </span><span style="color:#676E95;font-style:italic;">#查看tag</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-b</span><span style="color:#A6ACCD;"> [branch] </span><span style="color:#89DDFF;">[</span><span style="color:#A6ACCD;">tag</span><span style="color:#89DDFF;">]</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">#新建一个分支，指向某个tag</span></span></code></pre></div><h3 id="列出标签" tabindex="-1">列出标签 <a class="header-anchor" href="#列出标签" aria-label="Permalink to &quot;列出标签&quot;">​</a></h3><p>列出已有的标签可以使用命令：<strong>git tag</strong></p><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git tag</span></span></code></pre></div><h3 id="创建标签" tabindex="-1">创建标签 <a class="header-anchor" href="#创建标签" aria-label="Permalink to &quot;创建标签&quot;">​</a></h3><p>创建标签可以使用命令：<strong>git tag [name]</strong></p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">tag</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">v1.0</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.6.30/202207231718755.png" alt="image-20220723171848689" style="zoom:80%;"><h3 id="删除标签" tabindex="-1">删除标签 <a class="header-anchor" href="#删除标签" aria-label="Permalink to &quot;删除标签&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">tag</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">v1.0</span></span></code></pre></div><h3 id="推送至远程仓库" tabindex="-1">推送至远程仓库 <a class="header-anchor" href="#推送至远程仓库" aria-label="Permalink to &quot;推送至远程仓库&quot;">​</a></h3><p>将标签推送至远程仓库的命令格式：<strong>git push [远程仓库名] [标签名]</strong></p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">v1.0</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211030855586.png" alt="image-20221103085538507" style="zoom:80%;"><h3 id="分支标签" tabindex="-1">分支标签 <a class="header-anchor" href="#分支标签" aria-label="Permalink to &quot;分支标签&quot;">​</a></h3><p>检出标签时需要新建一个分支来指向某个标签，检出标签的命令格式：<strong>git checkout -b [分支名] [标签名]</strong></p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 方式一：创建分支并指向标签</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-b</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">b3</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">v1.0</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 方式二：创建标签，然后分支指向标签</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">tag</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">v1.2</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-b</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">v1.2</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.6.30/202207231719401.png" alt="image-20220723171952339" style="zoom:67%;"><h2 id="远程仓库" tabindex="-1">远程仓库 <a class="header-anchor" href="#远程仓库" aria-label="Permalink to &quot;远程仓库&quot;">​</a></h2><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.6.30/202207111856672.png" alt="image-20220711185602587" style="zoom:50%;"><p>和远程库的交互主要是<code>推</code>、<code>拉</code>，也就是写入和读取。</p><table><thead><tr><th style="text-align:left;"><strong>指令</strong></th><th style="text-align:left;"><strong>描述</strong></th></tr></thead><tbody><tr><td style="text-align:left;">git clone [git地址]</td><td style="text-align:left;">从远程仓库克隆到本地（当前目录）</td></tr><tr><td style="text-align:left;">git remote -v</td><td style="text-align:left;">查看所有远程仓库，不带参数<code>-v</code>只显示名称</td></tr><tr><td style="text-align:left;">git remote show [remote]</td><td style="text-align:left;">显示某个远程仓库的信息</td></tr><tr><td style="text-align:left;">git remote add [name] [url]</td><td style="text-align:left;">增加一个新的远程仓库，并命名</td></tr><tr><td style="text-align:left;">git remote rename [old] [new]</td><td style="text-align:left;">修改远程仓库名称</td></tr><tr><td style="text-align:left;"><strong>git pull [remote] [branch]</strong></td><td style="text-align:left;">取回远程仓库的变化，并与本地版本合并</td></tr><tr><td style="text-align:left;"><strong>git pull</strong></td><td style="text-align:left;">同上，针对当前分支</td></tr><tr><td style="text-align:left;">git fetch [remote]</td><td style="text-align:left;">获取远程仓库的所有变动到本地仓库，不会自动合并！需要手动合并</td></tr><tr><td style="text-align:left;"><strong>git push</strong></td><td style="text-align:left;">推送当前分支到远程仓库</td></tr><tr><td style="text-align:left;">git push [remote] [branch]</td><td style="text-align:left;">推送本地当前分支到远程仓库的指定分支</td></tr><tr><td style="text-align:left;">git push [remote] --force/-f</td><td style="text-align:left;">强行推送当前分支到远程仓库，即使有冲突，⚠️很危险！</td></tr><tr><td style="text-align:left;">git push [remote] --all</td><td style="text-align:left;">推送所有分支到远程仓库</td></tr><tr><td style="text-align:left;">git push –u</td><td style="text-align:left;">参数<code>–u</code>表示与远程分支建立关联，第一次执行的时候用，后面就不需要了</td></tr><tr><td style="text-align:left;">git remote rm [remote-name]</td><td style="text-align:left;">删除远程仓库</td></tr><tr><td style="text-align:left;">git pull --rebase</td><td style="text-align:left;">使用rebase的模式进行合并</td></tr></tbody></table><h3 id="查看远程仓库" tabindex="-1">查看远程仓库 <a class="header-anchor" href="#查看远程仓库" aria-label="Permalink to &quot;查看远程仓库&quot;">​</a></h3><blockquote><p>如果要查看已经配置的远程仓库服务器，可以执行 git remote 命令，它会列出每一个远程服务器的简称。如果已经克隆了远程仓库，<strong>那么至少应该能看到 origin ，这是 Git 克隆的仓库服务器的默认名字</strong>。</p></blockquote><blockquote><p>可以通过-v参数查看远程仓库更加详细的信息</p></blockquote><div class="language-apl"><button title="Copy Code" class="copy"></button><span class="lang">apl</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#89DDFF;">#</span><span style="color:#A6ACCD;"> 查看远程仓库</span></span>
<span class="line"><span style="color:#A6ACCD;">git remote</span></span>
<span class="line"><span style="color:#A6ACCD;">git remote </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">v</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.6.30/202207231709405.png" alt="image-20220723170926338" style="zoom:67%;"><h3 id="添加远程仓库" tabindex="-1">添加远程仓库 <a class="header-anchor" href="#添加远程仓库" aria-label="Permalink to &quot;添加远程仓库&quot;">​</a></h3><blockquote><p>格式：git remote add 简称(一般都是origin) 远程仓库地址，<strong>注意：一个本地仓库可以关联多个远程仓库</strong></p></blockquote><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">remote</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">xxxx.git</span></span></code></pre></div><p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211011010665.png" alt="image-20210926104723901"></p><h3 id="推送到远程" tabindex="-1">推送到远程 <a class="header-anchor" href="#推送到远程" aria-label="Permalink to &quot;推送到远程&quot;">​</a></h3><blockquote><p>小齐写完了代码，要提交到公司的代码库里，这个过程要用 <code>git push</code>。当然了，这么用会被打的。。毕竟还要 cr 呢。git push 可以推送本地分支、标签到远程仓库，也可以删除远程分支</p></blockquote><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 将本地分支的更新全部推送到远程仓库master分支，origin远程name，master本地name</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 删除远程branchname分支</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-d</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#C3E88D;">branchnam</span><span style="color:#A6ACCD;">e</span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">   </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">#  推送所有标签</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--tags</span></span></code></pre></div><blockquote><p>如果我们在dev开发完，或者就想把文件推送到远程仓库，给别的伙伴看看，就可以使用git push origin dev~如果直接<code>push</code>可能会失败，因为可能存在冲突，所以在<code>push</code>之前往往会先<code>pull</code>一下，如果存在冲突本地解决。<code>push</code>成功后本地的远程分支引用会更新，与本地分支指向同一节点</p></blockquote><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">.</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-m</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">提交</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span></span></code></pre></div><p>在使用git push命令将本地文件推送至码云远程仓库时，如果是第一次操作，需要进行身份认证，认证通过才可以推送</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211011012861.png" alt="image-20210926105913504" style="zoom:80%;"><p>注意：上面的用户名和密码对应的就是我们在码云上注册的用户名和密码，认证通过后会将用户名和密码保存到windows系统中（如下图），后续再推送则无需重复输入用户名和密码。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211011012863.png" alt="image-20210926110810630" style="zoom:80%;"><p>推送完成后可以到远程仓库中查看文件的变化。</p><h3 id="克隆远程仓库" tabindex="-1">克隆远程仓库 <a class="header-anchor" href="#克隆远程仓库" aria-label="Permalink to &quot;克隆远程仓库&quot;">​</a></h3><blockquote><p>新来的实习生首先要 clone 整个项目到本地来，然后才能增删改查。如果你想获得一份已经存在了的 Git 远程仓库的拷贝，这时就要用到 git clone 命令。 Git 克隆的是该 Git 仓库服务器上的几乎所有数据（包括日志信息、历史记录等）。克隆仓库的命令格式： git clone 远程仓库地址</p></blockquote><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">clone</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">xxx.git</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211011012263.png" alt="image-20221101101201191" style="zoom:80%;"><h3 id="更新本地仓库" tabindex="-1">更新本地仓库 <a class="header-anchor" href="#更新本地仓库" aria-label="Permalink to &quot;更新本地仓库&quot;">​</a></h3><blockquote><p>小齐提交了新的代码之后，领导要审查呀，所以用 <code>git pull</code> 把最新的代码拉取下来瞅瞅。<strong>git</strong> <strong>pull</strong> 命令的作用是从远程仓库获取最新版本并合并到本地仓库。git pull = fetch + merge</p></blockquote><blockquote><p><strong>注意</strong>：如果当前本地仓库不是从远程仓库克隆，而是本地创建的仓库，并且仓库中存在文件，此时再从远程仓库拉取文件的时候会报错（fatal: refusing to merge unrelated histories ）解决此问题可以在git pull命令后加入参数--allow-unrelated-histories</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092104178.png" alt="image-20230409210427975" style="zoom:80%;"><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 直接拉取远程仓库的新内容</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">pull</span><span style="color:#A6ACCD;">  </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 从远端origin的master分支更新版本库</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># git pull &lt;远端&gt; &lt;分支&gt;</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">pull</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 抓取远程仓库所有分支更新并合并到本地，不要快进合并</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">pull</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--no-ff</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 将远程master分支合并到当前本地master分支，冒号后面表示本地分支</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">pull</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master:master</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">pull</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--allow-unrelated-histories</span></span></code></pre></div><h3 id="获取远程更新" tabindex="-1">获取远程更新 <a class="header-anchor" href="#获取远程更新" aria-label="Permalink to &quot;获取远程更新&quot;">​</a></h3><p><code>git fetch</code> 这个操作是将远程库的数据下载到本地库，但是工作区中的文件没有更新。</p><p>git fetch 从目标分支收集当前分支中不存在的任何提交，并将它们存储在本地存储库中。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.6.30/202207111857333.png" alt="image-20220711185703251" style="zoom:50%;"><p>而要谈 <code>get merge</code>，我们还需要先讲下<code>分支</code>。<code>merge</code> 是 <code>git pull</code> 默认的选项，合并其实还有另外一种方法：<code>rebase</code>，中文叫做<strong>变基</strong>。</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">fetch</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">远程仓库地址/分支名</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">fetch</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--all</span><span style="color:#A6ACCD;">  </span><span style="color:#676E95;font-style:italic;">#拉取所有远端的最新代码</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">fetch</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;font-style:italic;">#拉取远程最新master分支代码</span></span></code></pre></div><p>fetch与pull有什么不同？两者都是从服务端获取更新，主要区别是<code>fetch</code>不会自动合并，不会影响当前工作区内容</p><blockquote><p>git pull<code>=</code>git fetch<code>+</code>git merge</p></blockquote><ul><li>如下面图中，<code>git fetch</code>只获取了更新，并未影响<code>master</code>、<code>HEAD</code>的位置。</li><li>要更新<code>master</code>、<code>HEAD</code>的位置需要手动执行<code>git merge</code>合并。</li></ul><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304092105353.png" alt="image-20230409210556164" style="zoom:67%;"><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># fetch只更新版本库</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">fetch</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 执行合并，合并自己</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">merge</span></span></code></pre></div><h3 id="移除远程地址" tabindex="-1">移除远程地址 <a class="header-anchor" href="#移除远程地址" aria-label="Permalink to &quot;移除远程地址&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">remote</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">remove</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 再进行查看，发现已经没有远程仓库地址了</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">remote</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-v</span></span></code></pre></div><h2 id="其他命令" tabindex="-1">其他命令 <a class="header-anchor" href="#其他命令" aria-label="Permalink to &quot;其他命令&quot;">​</a></h2><h3 id="archive" tabindex="-1">archive <a class="header-anchor" href="#archive" aria-label="Permalink to &quot;archive&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 生成一个可供发布的压缩包</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">archive</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 打补丁</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">apply</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">../sync.patch</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 测试补丁能否成功</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">apply</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--check</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">../sync.patch</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 查看Git的版本</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--version</span></span></code></pre></div><h3 id="rebase-谨慎使用" tabindex="-1">rebase (谨慎使用) <a class="header-anchor" href="#rebase-谨慎使用" aria-label="Permalink to &quot;rebase (谨慎使用)&quot;">​</a></h3><p><strong>将一个分支上所有的提交历史都应用到另一个分支上，不要在一个已经公开的远端分支上使用 rebase</strong></p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 将experimentBranch应用到master上面</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># git rebase &lt;basebranch&gt; &lt;topicbranch&gt;</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rebase</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">experimentBranch</span></span></code></pre></div><h3 id="ci" tabindex="-1">ci <a class="header-anchor" href="#ci" aria-label="Permalink to &quot;ci&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ci</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&lt;</span><span style="color:#C3E88D;">fil</span><span style="color:#A6ACCD;">e</span><span style="color:#89DDFF;">&gt;</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ci</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">.</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 将git add, git rm和git ci等操作都合并在一起做</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ci</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-a</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ci</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-am</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">some comments</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 修改最后一次提交记录</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ci</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--amend</span></span></code></pre></div><h3 id="grep" tabindex="-1">grep <a class="header-anchor" href="#grep" aria-label="Permalink to &quot;grep&quot;">​</a></h3><p>可以在版本库中快速查找</p><p>可选配置：</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 感谢Travis Jeffery提供的以下用法：</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 在搜索结果中显示行号</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--global</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">grep.lineNumber</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">true</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 是搜索结果可读性更好</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--global</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">alias.g</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">grep --break --heading --line-number</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 在所有的java中查找variableName</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">grep</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">variableName</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">*.java</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 搜索包含 &quot;arrayListName&quot; 和, &quot;add&quot; 或 &quot;remove&quot; 的所有行</span></span>
<span class="line"><span style="color:#FFCB6B;">$</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">grep</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-e</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">arrayListName</span><span style="color:#89DDFF;">&#39;</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--and</span><span style="color:#A6ACCD;"> \( </span><span style="color:#C3E88D;">-e</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-e</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">remove</span><span style="color:#A6ACCD;"> \)</span></span></code></pre></div><h2 id="实战演练⭐" tabindex="-1">实战演练⭐ <a class="header-anchor" href="#实战演练⭐" aria-label="Permalink to &quot;实战演练⭐&quot;">​</a></h2><p>这些都是要在当前文件所在目录进行的</p><h3 id="本地操作" tabindex="-1">本地操作 <a class="header-anchor" href="#本地操作" aria-label="Permalink to &quot;本地操作&quot;">​</a></h3><div class="language-c"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;">// 初始化git存储库</span></span>
<span class="line"><span style="color:#A6ACCD;">git init</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">//0、本地创建并切换login分支</span></span>
<span class="line"><span style="color:#A6ACCD;">git checkout </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">b login</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">//查看文件状态</span></span>
<span class="line"><span style="color:#A6ACCD;">git status </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">//1、所有文件添加到暂存区，再次查看文件名由红色变成了绿色</span></span>
<span class="line"><span style="color:#A6ACCD;">git add .</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">//2、提交到本地仓库</span></span>
<span class="line"><span style="color:#A6ACCD;">git commit </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">m </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">完成了登录功能</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">//3、查看当前所在分支，和目前所有分支</span></span>
<span class="line"><span style="color:#A6ACCD;">git branch</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">//4、切换到要合并的分支</span></span>
<span class="line"><span style="color:#A6ACCD;">git checkout master</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">//5、将login分支代码合并到master分支</span></span>
<span class="line"><span style="color:#A6ACCD;">git merge login</span></span></code></pre></div><h3 id="提交到远程仓库" tabindex="-1">提交到远程仓库 <a class="header-anchor" href="#提交到远程仓库" aria-label="Permalink to &quot;提交到远程仓库&quot;">​</a></h3><div class="language-c"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;">//6、配置远程仓库，这是一开始创建仓库时就会提示好的</span></span>
<span class="line"><span style="color:#A6ACCD;">git remote add origin https:</span><span style="color:#676E95;font-style:italic;">//gitee.com/sure-s-renshuo/vue_shop.git</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">//7、提交到Gitee中，前提是配置好远程仓库，下次推送文件时，可以使用 git push。</span></span>
<span class="line"><span style="color:#A6ACCD;">git push </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">u origin master</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">//8、此时可以直接提交</span></span>
<span class="line"><span style="color:#A6ACCD;">git push</span></span></code></pre></div><p>切换到login分支并提交login分支</p><div class="language-c"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;">//此时远程仓库并没有login分支，因此需要执行命令,并且提交了代码到login分支里</span></span>
<span class="line"><span style="color:#A6ACCD;">git push </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">u origin login</span></span></code></pre></div><p>上下两种方法最后都可以</p><p>完成user内容后，查看分支</p><div class="language-c"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git branch</span></span></code></pre></div><h3 id="创建并切换到user分支" tabindex="-1">创建并切换到user分支 <a class="header-anchor" href="#创建并切换到user分支" aria-label="Permalink to &quot;创建并切换到user分支&quot;">​</a></h3><div class="language-c"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git checkout </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">b user</span></span></code></pre></div><div class="language-c"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;">//1、所有文件添加到暂存区，再次查看文件名由红色变成了绿色</span></span>
<span class="line"><span style="color:#A6ACCD;">git add .</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">//2、提交到本地仓库</span></span>
<span class="line"><span style="color:#A6ACCD;">git commit </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">m </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">完成用户列表开发</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">//3、远程仓库对应创建分支并推送，如果远程有该分支则直接git push即可</span></span>
<span class="line"><span style="color:#A6ACCD;">git push </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">u origin user</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">//4、切换到主分支</span></span>
<span class="line"><span style="color:#A6ACCD;">git checkout master</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">//5、合并到主分支</span></span>
<span class="line"><span style="color:#A6ACCD;">git merge login</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">//6、将主分支的代码也提交</span></span>
<span class="line"><span style="color:#A6ACCD;">git push</span></span></code></pre></div><h3 id="权限列表分支" tabindex="-1">权限列表分支 <a class="header-anchor" href="#权限列表分支" aria-label="Permalink to &quot;权限列表分支&quot;">​</a></h3><div class="language-c"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;">//查看分支</span></span>
<span class="line"><span style="color:#A6ACCD;">git branch</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">//创建并切换分支</span></span>
<span class="line"><span style="color:#A6ACCD;">git checkout </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">b rights</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">//在远程创建rights分支</span></span>
<span class="line"><span style="color:#A6ACCD;">git push </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">u origin rights</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">//如果后面切换分支失败则再次执行下面三步，git status查看文件状态</span></span>
<span class="line"><span style="color:#A6ACCD;">git add .</span></span>
<span class="line"><span style="color:#A6ACCD;">git commit </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">m </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">完成了权限列表的开发</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#A6ACCD;">git push</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;">//切换到主分支</span></span>
<span class="line"><span style="color:#A6ACCD;">git checkout master</span></span>
<span class="line"><span style="color:#A6ACCD;">git merge rights</span></span>
<span class="line"><span style="color:#A6ACCD;">git push</span></span></code></pre></div><p>后面可以通过git checkout 分支名 切换分支，文件列表就会进行相应改变，很实用</p><p>注意：如果git push失败，那么可以强制推送</p><div class="language-c"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#A6ACCD;">git push </span><span style="color:#89DDFF;">-</span><span style="color:#A6ACCD;">f 强制将本地文件推送至远程，这样会将远程仓库的已有的文件清掉</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img/image-20211223142241154.png" alt="image-20211223142241154" style="zoom:67%;"><h1 id="图形化工具⭐" tabindex="-1">图形化工具⭐ <a class="header-anchor" href="#图形化工具⭐" aria-label="Permalink to &quot;图形化工具⭐&quot;">​</a></h1><h2 id="下载-安装" tabindex="-1">下载 &amp; 安装 <a class="header-anchor" href="#下载-安装" aria-label="Permalink to &quot;下载 &amp; 安装&quot;">​</a></h2><h3 id="下载github-desktop" tabindex="-1">下载GitHub Desktop <a class="header-anchor" href="#下载github-desktop" aria-label="Permalink to &quot;下载GitHub Desktop&quot;">​</a></h3><p>Git官网提供对应得下载链接页面：<a href="https://git-scm.com/downloads/guis" target="_blank" rel="noreferrer">https://git-scm.com/downloads/guis</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304070934425.png" alt="image-20230407093428237" style="zoom:80%;"><h3 id="安装和汉化" tabindex="-1">安装和汉化 <a class="header-anchor" href="#安装和汉化" aria-label="Permalink to &quot;安装和汉化&quot;">​</a></h3><p>无安装过程，安装完成后，弹出应用界面</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304070941337.png" alt="image-20230407094115207" style="zoom:80%;"><p>汉化：<a href="https://blog.csdn.net/qq_46365857/article/details/112581517" target="_blank" rel="noreferrer">https://blog.csdn.net/qq_46365857/article/details/112581517</a></p><p>下载：<a href="https://github.com/robotze/GithubDesktopZhTool/releases/tag/3.2.0" target="_blank" rel="noreferrer">https://github.com/robotze/GithubDesktopZhTool/releases/tag/3.2.0</a></p><p>访问<code>https://github.com/robotze/-GitHubDesktop_ZH</code>，下载中文汉化包。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304070945832.png" alt="image-20230407094528722" style="zoom:80%;"><p>解压<code>GithubDesktop汉化工具.7z</code>，执行<code>GithubDesktopZhTool.exe</code>程序</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304070945056.png" alt="image-20230407094542951" style="zoom:80%;"><p>点击汉化按钮，汉化成功。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304070945934.png" alt="image-20230407094559830" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304070944695.png" alt="image-20230407094425571" style="zoom:80%;"><h3 id="配置姓名邮箱" tabindex="-1">配置姓名邮箱 <a class="header-anchor" href="#配置姓名邮箱" aria-label="Permalink to &quot;配置姓名邮箱&quot;">​</a></h3><p>点击软件得File菜单后，选择Options, 设定软件得操作用户名称及对应得邮箱地址。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304070947903.png" alt="image-20230407094738803" style="zoom:80%;"><h3 id="主题样式" tabindex="-1">主题样式 <a class="header-anchor" href="#主题样式" aria-label="Permalink to &quot;主题样式&quot;">​</a></h3><p>可以根据自己得偏好设定软件主题样式。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304070947338.png" alt="image-20230407094759242" style="zoom:80%;"><h3 id="全屏" tabindex="-1">全屏 <a class="header-anchor" href="#全屏" aria-label="Permalink to &quot;全屏&quot;">​</a></h3><p>如果觉得软件界面比较小，可以适当进行调整或全屏</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304070948888.png" alt="image-20230407094824786" style="zoom:80%;"><h2 id="创建本地仓库" tabindex="-1">创建本地仓库 <a class="header-anchor" href="#创建本地仓库" aria-label="Permalink to &quot;创建本地仓库&quot;">​</a></h2><h3 id="创建仓库" tabindex="-1">创建仓库 <a class="header-anchor" href="#创建仓库" aria-label="Permalink to &quot;创建仓库&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304070949516.png" alt="image-20230407094921406" style="zoom:80%;"><blockquote><p>注意，本地路径只需要指定父文件夹即可，最终路径是和名称进行拼接的</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304070952717.png" alt="image-20230407095226613" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304070954951.png" alt="image-20230407095449818" style="zoom:80%;"><h3 id="添加仓库" tabindex="-1">添加仓库 <a class="header-anchor" href="#添加仓库" aria-label="Permalink to &quot;添加仓库&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304070956860.png" alt="image-20230407095640766" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304070956080.png" alt="image-20230407095620988" style="zoom:80%;"><h3 id="切换仓库" tabindex="-1">切换仓库 <a class="header-anchor" href="#切换仓库" aria-label="Permalink to &quot;切换仓库&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304070957050.png" alt="image-20230407095755936" style="zoom:80%;"><h3 id="删除仓库" tabindex="-1">删除仓库 <a class="header-anchor" href="#删除仓库" aria-label="Permalink to &quot;删除仓库&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304070959206.png" alt="image-20230407095919092" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071000778.png" alt="image-20230407100012684" style="zoom:80%;"><h2 id="文件操作-1" tabindex="-1">文件操作 <a class="header-anchor" href="#文件操作-1" aria-label="Permalink to &quot;文件操作&quot;">​</a></h2><h3 id="新增文件-1" tabindex="-1">新增文件 <a class="header-anchor" href="#新增文件-1" aria-label="Permalink to &quot;新增文件&quot;">​</a></h3><p>当工作区域创建了一份新文件，工具可以自动识别并进行对应得显示</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071001058.png" alt="image-20230407100126881" style="zoom:80%;"><p>此时Git仓库中并没有这份文件，所以需要执行commit操作，将文件保存到Git仓库中。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071001757.png" alt="image-20230407100159671" style="zoom:80%;"><h3 id="忽略文件" tabindex="-1">忽略文件 <a class="header-anchor" href="#忽略文件" aria-label="Permalink to &quot;忽略文件&quot;">​</a></h3><p>如果某一个文件或某一类得文件，不想被Git软件进行管理。可以在忽略文件中进行设定</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071004205.png" alt="image-20230407100406103" style="zoom:80%;"><h3 id="修改文件" tabindex="-1">修改文件 <a class="header-anchor" href="#修改文件" aria-label="Permalink to &quot;修改文件&quot;">​</a></h3><p>修改文件只是将工作区域得文件进行修改，但是对于Git软件来讲，其实本质上还是提交，因为底层会生成新得文件</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071004770.png" alt="image-20230407100426677" style="zoom:80%;"><h3 id="删除文件-2" tabindex="-1">删除文件 <a class="header-anchor" href="#删除文件-2" aria-label="Permalink to &quot;删除文件&quot;">​</a></h3><p>删除文件对于Git软件来讲，依然是一个提交</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071004615.png" alt="image-20230407100447519" style="zoom:80%;"><p>提交后，最新版本得文件也会被“删除”</p><h3 id="历史记录" tabindex="-1">历史记录 <a class="header-anchor" href="#历史记录" aria-label="Permalink to &quot;历史记录&quot;">​</a></h3><p>如果存在多次得提交操作得话，可以查看提交得历史记录</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071005492.png" alt="image-20230407100510375" style="zoom:80%;"><h2 id="分支操作-1" tabindex="-1">分支操作 <a class="header-anchor" href="#分支操作-1" aria-label="Permalink to &quot;分支操作&quot;">​</a></h2><h3 id="默认分支" tabindex="-1">默认分支 <a class="header-anchor" href="#默认分支" aria-label="Permalink to &quot;默认分支&quot;">​</a></h3><p>软件创建仓库时，默认创建得分支为main</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071006153.png" alt="image-20230407100628067" style="zoom:80%;"><p>点击右键可以改名</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071007819.png" alt="image-20230407100712731" style="zoom:80%;"><h3 id="创建分支-1" tabindex="-1">创建分支 <a class="header-anchor" href="#创建分支-1" aria-label="Permalink to &quot;创建分支&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071007727.png" alt="image-20230407100752637" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071008361.png" alt="image-20230407100828270" style="zoom:80%;"><h3 id="切换分支-1" tabindex="-1">切换分支 <a class="header-anchor" href="#切换分支-1" aria-label="Permalink to &quot;切换分支&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071009548.png" alt="image-20230407100927456" style="zoom:80%;"><h3 id="删除分支-1" tabindex="-1">删除分支 <a class="header-anchor" href="#删除分支-1" aria-label="Permalink to &quot;删除分支&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071010782.png" alt="image-20230407101034698" style="zoom:80%;"><h3 id="合并分支-1" tabindex="-1">合并分支 <a class="header-anchor" href="#合并分支-1" aria-label="Permalink to &quot;合并分支&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071012414.png" alt="image-20230407101214312" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071013422.png" alt="image-20230407101304328" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071013591.png" alt="image-20230407101321498" style="zoom:80%;"><h3 id="冲突解决" tabindex="-1">冲突解决 <a class="header-anchor" href="#冲突解决" aria-label="Permalink to &quot;冲突解决&quot;">​</a></h3><blockquote><p>在main分支下，新建b.txt，然后在第一行写上123，然后提交文件</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071051388.png" alt="image-20230407105149256" style="zoom:80%;"><blockquote><p>切换到user分支，此时文件夹中没有b.txt，再次创建b.txt，写入456</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071053166.png" alt="image-20230407105317044" style="zoom:80%;"><blockquote><p>再次切换到main分支，合并user分支</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071054682.png" alt="image-20230407105441578" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071055214.png" alt="image-20230407105500123" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071055581.png" alt="image-20230407105512499" style="zoom:80%;"><blockquote><p>删除多余内容，进行保存，即可再次提交</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071055110.png" alt="image-20230407105552029" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071056747.png" alt="image-20230407105604661" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071056894.png" alt="image-20230407105633814" style="zoom:80%;"><h2 id="标签操作-1" tabindex="-1">标签操作 <a class="header-anchor" href="#标签操作-1" aria-label="Permalink to &quot;标签操作&quot;">​</a></h2><h3 id="创建标签-1" tabindex="-1">创建标签 <a class="header-anchor" href="#创建标签-1" aria-label="Permalink to &quot;创建标签&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071014738.png" alt="image-20230407101455639" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071015506.png" alt="image-20230407101524421" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071016394.png" alt="image-20230407101625303" style="zoom:80%;"><h3 id="删除标签-1" tabindex="-1">删除标签 <a class="header-anchor" href="#删除标签-1" aria-label="Permalink to &quot;删除标签&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071017276.png" alt="image-20230407101734180" style="zoom:80%;"><h2 id="远程仓库-1" tabindex="-1">远程仓库 <a class="header-anchor" href="#远程仓库-1" aria-label="Permalink to &quot;远程仓库&quot;">​</a></h2><h3 id="克隆仓库" tabindex="-1">克隆仓库 <a class="header-anchor" href="#克隆仓库" aria-label="Permalink to &quot;克隆仓库&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071047369.png" alt="image-20230407104720263" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071018421.png" alt="image-20230407101854332" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071021793.png" alt="image-20230407102147701" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071022698.png" alt="image-20230407102231599" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071022536.png" alt="image-20230407102249417" style="zoom:80%;"><h3 id="拉取文件" tabindex="-1">拉取文件 <a class="header-anchor" href="#拉取文件" aria-label="Permalink to &quot;拉取文件&quot;">​</a></h3><p>远程仓库更新了文件</p><p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071023803.png" alt="image-20230407102324707"></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071023933.png" alt="image-20230407102339808" style="zoom:80%;"><p>拉取文件中</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071024689.png" alt="image-20230407102406570" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071024326.png" alt="image-20230407102420224" style="zoom:80%;"><h3 id="推送文件" tabindex="-1">推送文件 <a class="header-anchor" href="#推送文件" aria-label="Permalink to &quot;推送文件&quot;">​</a></h3><p>本地创建新文件</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071024439.png" alt="image-20230407102451273" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071025992.png" alt="image-20230407102511898" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071025632.png" alt="image-20230407102526531" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071025770.png" alt="image-20230407102542667" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071026319.png" alt="image-20230407102600220" style="zoom:80%;"><h2 id="readme-gitignore" tabindex="-1">README &amp; .gitignore <a class="header-anchor" href="#readme-gitignore" aria-label="Permalink to &quot;README &amp; .gitignore&quot;">​</a></h2><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071104990.png" alt="image-20230407110455905" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071104745.png" alt="image-20230407110438647" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071108745.png" alt="image-20230407110840642" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071109174.png" alt="image-20230407110910091" style="zoom:80%;"><h2 id="文件图标和内容比对" tabindex="-1">文件图标和内容比对 <a class="header-anchor" href="#文件图标和内容比对" aria-label="Permalink to &quot;文件图标和内容比对&quot;">​</a></h2><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071113748.png" alt="image-20230407111328659" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071114894.png" alt="image-20230407111408812" style="zoom:80%;"><h1 id="远程服务器" tabindex="-1">远程服务器 <a class="header-anchor" href="#远程服务器" aria-label="Permalink to &quot;远程服务器&quot;">​</a></h1><h2 id="远程服务器-1" tabindex="-1">远程服务器 <a class="header-anchor" href="#远程服务器-1" aria-label="Permalink to &quot;远程服务器&quot;">​</a></h2><p>在之前的操作中，所有的操作都是基于本地机器完成的。如果在公司中，一个项目是共用一个版本库的。那么所有的开发人员都应该对同一个版本库进行操作。因为Git软件本身就是用于Linux系统开发所设计的版本管理软件，所以项目中搭建的共享版本库也应该以linux系统为主。那么接下来，咱们就演示一下在CentsOS服务器中搭建Git服务器。</p><h3 id="下载git软件-linux版本" tabindex="-1">下载Git软件（Linux版本） <a class="header-anchor" href="#下载git软件-linux版本" aria-label="Permalink to &quot;下载Git软件（Linux版本）&quot;">​</a></h3><p>官网下载地址：<a href="https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.38.1.tar.gz" target="_blank" rel="noreferrer">https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.38.1.tar.gz</a></p><p>将下载后的压缩文件上传到Linux系统中</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071422673.png" alt="image-20230407142226496" style="zoom:80%;"><h3 id="安装git软件" tabindex="-1">安装Git软件 <a class="header-anchor" href="#安装git软件" aria-label="Permalink to &quot;安装Git软件&quot;">​</a></h3><h4 id="解压git" tabindex="-1">解压Git <a class="header-anchor" href="#解压git" aria-label="Permalink to &quot;解压Git&quot;">​</a></h4><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 将压缩文件解压到自定义位置</span></span>
<span class="line"><span style="color:#FFCB6B;">tar</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-zxvf</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git-2.38.1.tar.gz</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-C</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/module/</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 可以更改名字，变得简短一些，好操作</span></span>
<span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/module</span></span>
<span class="line"><span style="color:#FFCB6B;">mv</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git-2.38.1/</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span></span></code></pre></div><h4 id="安装依赖" tabindex="-1">安装依赖 <a class="header-anchor" href="#安装依赖" aria-label="Permalink to &quot;安装依赖&quot;">​</a></h4><p>解压后，我们需要编译源码，不过在此之前需要安装编译所需要的依赖，耐心等待安装完成，中途出现提示的时候输入y并按回车。</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">yum</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">install</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-y</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">curl-devel</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">expat-devel</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">gettext-devel</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">openssl-devel</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">zlib-devel</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">gcc</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">perl-ExtUtils-MakeMaker</span></span></code></pre></div><h4 id="删除旧版git" tabindex="-1">删除旧版Git <a class="header-anchor" href="#删除旧版git" aria-label="Permalink to &quot;删除旧版Git&quot;">​</a></h4><p>安装编译源码所需依赖的时候，yum操作回自动安装旧版本的Git。我们这里需要卸载这个旧版的Git</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 删除旧版本的Git</span></span>
<span class="line"><span style="color:#FFCB6B;">yum</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-y</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">remove</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span></span></code></pre></div><h4 id="编译、安装git" tabindex="-1">编译、安装Git <a class="header-anchor" href="#编译、安装git" aria-label="Permalink to &quot;编译、安装Git&quot;">​</a></h4><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 进入到Git软件的解压目录</span></span>
<span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/module/git</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 编译时，prefix设定为Git软件安装目录</span></span>
<span class="line"><span style="color:#FFCB6B;">make</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prefix=/usr/local/git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">all</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 安装Git</span></span>
<span class="line"><span style="color:#FFCB6B;">make</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">prefix=/usr/local/git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">install</span></span></code></pre></div><h4 id="配置环境变量" tabindex="-1">配置环境变量 <a class="header-anchor" href="#配置环境变量" aria-label="Permalink to &quot;配置环境变量&quot;">​</a></h4><p>修改linux系统中/etc/profile文件，配置环境变量</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 配置环境变量</span></span>
<span class="line"><span style="color:#C792EA;">export</span><span style="color:#A6ACCD;"> PATH</span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;">$PATH</span><span style="color:#C3E88D;">:/usr/local/git/bin</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 刷新环境，让环境变量立即生效</span></span>
<span class="line"><span style="color:#82AAFF;">source</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/etc/profile</span></span></code></pre></div><h4 id="建立链接文件" tabindex="-1">建立链接文件 <a class="header-anchor" href="#建立链接文件" aria-label="Permalink to &quot;建立链接文件&quot;">​</a></h4><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># git安装路径是/usr/local/git，不是默认路径</span></span>
<span class="line"><span style="color:#FFCB6B;">ln</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-s</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/usr/local/git/bin/git-upload-pack</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/usr/bin/git-upload-pack</span></span>
<span class="line"><span style="color:#FFCB6B;">ln</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-s</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/usr/local/git/bin/git-receive-pack</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/usr/bin/git-receive-pack</span></span></code></pre></div><h4 id="测试安装" tabindex="-1">测试安装 <a class="header-anchor" href="#测试安装" aria-label="Permalink to &quot;测试安装&quot;">​</a></h4><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 获取git软件版本</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--version</span></span></code></pre></div><h3 id="创建git用户" tabindex="-1">创建Git用户 <a class="header-anchor" href="#创建git用户" aria-label="Permalink to &quot;创建Git用户&quot;">​</a></h3><p>因为Git服务器需要安装在linux系统上，当使用远程客户端操作时，就需要提供相应的Git账号进行提交的，如果你的仓库文件的用户不是git的话，是root用户或者别的用户，那么你git push ,它是不允许的，因为你的git用户没有权限。你可以给这个文件创立git用户，或者修改文件夹的权限让所有用户都可以更改</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 增加用户</span></span>
<span class="line"><span style="color:#FFCB6B;">adduser</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 设定密码</span></span>
<span class="line"><span style="color:#FFCB6B;">passwd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span></span></code></pre></div><h3 id="ssh免密登录" tabindex="-1">SSH免密登录 <a class="header-anchor" href="#ssh免密登录" aria-label="Permalink to &quot;SSH免密登录&quot;">​</a></h3><h4 id="服务器端操作" tabindex="-1">服务器端操作 <a class="header-anchor" href="#服务器端操作" aria-label="Permalink to &quot;服务器端操作&quot;">​</a></h4><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 进入用户目录</span></span>
<span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/home/git</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 在git用户根目录创建.ssh目录</span></span>
<span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">mkdir</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">.ssh</span></span>
<span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">touch</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">.ssh/authorized_keys</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 设定.ssh目录，authorized_keys的权限</span></span>
<span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">chmod</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-R</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">700</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/home/git/.ssh</span></span>
<span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">chmod</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">600</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/home/git/.ssh/authorized_keys</span></span></code></pre></div><h4 id="客户端端操作" tabindex="-1">客户端端操作 <a class="header-anchor" href="#客户端端操作" aria-label="Permalink to &quot;客户端端操作&quot;">​</a></h4><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 在客户端生成SSH密钥</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 默认生成的密钥用户就是当前用户，需要和之前的全局配置保持一致</span></span>
<span class="line"><span style="color:#FFCB6B;">user.name</span><span style="color:#A6ACCD;">=18801@LAPTOP-J9IRK5BM</span></span>
<span class="line"><span style="color:#FFCB6B;">user.email</span><span style="color:#A6ACCD;">=18801@LAPTOP-J9IRK5BM</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 按照提示三次回车即可</span></span>
<span class="line"><span style="color:#FFCB6B;">ssh-keygen</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-t</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rsa</span></span></code></pre></div><p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071411084.jpg" alt="img"></p><p>在用户根目录的.ssh文件夹内，id_rsa.pub就是我们要的公钥</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071427361.png" alt="image-20230407142723255" style="zoom:80%;"><p>将文件中的内容复制到服务器端的.ssh/authorized_keys文件中</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071427136.png" alt="image-20230407142738033" style="zoom:80%;"><h3 id="创建git版本库" tabindex="-1">创建Git版本库 <a class="header-anchor" href="#创建git版本库" aria-label="Permalink to &quot;创建Git版本库&quot;">​</a></h3><h4 id="创建文件目录" tabindex="-1">创建文件目录 <a class="header-anchor" href="#创建文件目录" aria-label="Permalink to &quot;创建文件目录&quot;">​</a></h4><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 进入用户目录</span></span>
<span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/home/git</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 创建版本库目录</span></span>
<span class="line"><span style="color:#FFCB6B;">mkdir</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git-rep</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 设定文件所属用户</span></span>
<span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">chown</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git:git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git-rep</span></span></code></pre></div><h4 id="初始化版本库-1" tabindex="-1">初始化版本库 <a class="header-anchor" href="#初始化版本库-1" aria-label="Permalink to &quot;初始化版本库&quot;">​</a></h4><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 进入仓库目录</span></span>
<span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/home/git/git-rep</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 初始化仓库，和前面的git init略有不同</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">init</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-bare</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">test.git</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 设定文件所属用户</span></span>
<span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">chown</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-R</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git:git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">test.git</span></span></code></pre></div><h3 id="远程访问git版本库" tabindex="-1">远程访问Git版本库 <a class="header-anchor" href="#远程访问git版本库" aria-label="Permalink to &quot;远程访问Git版本库&quot;">​</a></h3><h4 id="将远程仓库克隆到本地" tabindex="-1">将远程仓库克隆到本地 <a class="header-anchor" href="#将远程仓库克隆到本地" aria-label="Permalink to &quot;将远程仓库克隆到本地&quot;">​</a></h4><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 将远程仓库克隆到本地，形成本地仓库</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 克隆远程仓库 =&gt; 用户@主机名:仓库地址</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">clone</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git@linux1:/home/git/git-rep/test.git</span></span></code></pre></div><h4 id="提交文件到本地仓库" tabindex="-1">提交文件到本地仓库 <a class="header-anchor" href="#提交文件到本地仓库" aria-label="Permalink to &quot;提交文件到本地仓库&quot;">​</a></h4><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 增加文件</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">client.txt</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 提交文件</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-m</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">client</span><span style="color:#89DDFF;">&#39;</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071428139.png" alt="image-20230407142858018" style="zoom:80%;"><h4 id="将本地仓库同步到远程仓库" tabindex="-1">将本地仓库同步到远程仓库 <a class="header-anchor" href="#将本地仓库同步到远程仓库" aria-label="Permalink to &quot;将本地仓库同步到远程仓库&quot;">​</a></h4><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 同步远程仓库</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 远程仓库默认有个别名叫origin，将本地仓库的文件推送（push）到远程仓库</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># git push 远程仓库别名 分支名称 </span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071644976.png" alt="image-20230407164458851" style="zoom:80%;"><h4 id="查看远程仓库-1" tabindex="-1">查看远程仓库 <a class="header-anchor" href="#查看远程仓库-1" aria-label="Permalink to &quot;查看远程仓库&quot;">​</a></h4><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 服务器端切换用户</span></span>
<span class="line"><span style="color:#FFCB6B;">su</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 进入仓库</span></span>
<span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/home/git/git-rep/test.git</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 切换到主干分支</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">checkout</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 查看git日志</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">log</span></span></code></pre></div><h2 id="github服务器" tabindex="-1">GitHub服务器 <a class="header-anchor" href="#github服务器" aria-label="Permalink to &quot;GitHub服务器&quot;">​</a></h2><p>公司中，我们可以搭建中央服务器让项目组开发人员共享代码，但是如果我们的开发人员都是通过互联网进行协作，而不是在同一个地方，那么开发时，程序文件代码的版本管理就显得更加重要，这就需要搭建一个互联网的版本库，让不同地点的人都可以进行访问。这里我们不用自己搭建。因为GitHub网站已经帮助我们提供了共享版本库功能。所以我们接下来就讲解一下，如何使用GitHub网站所提供的功能使用Git。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071646037.png" alt="image-20230407164633768" style="zoom:80%;"><h3 id="注册网站会员" tabindex="-1">注册网站会员 <a class="header-anchor" href="#注册网站会员" aria-label="Permalink to &quot;注册网站会员&quot;">​</a></h3><p>GitHub官网地址：<a href="https://github.com/%EF%BC%8C%E5%A1%AB%E5%86%99%E4%BD%A0%E7%9A%84%E9%82%AE%E7%AE%B1%E5%9C%B0%E5%9D%80%E5%92%8C%E5%AF%86%E7%A0%81%EF%BC%8C%E5%A7%93%E5%90%8D" target="_blank" rel="noreferrer">https://github.com/，填写你的邮箱地址和密码，姓名</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071646870.png" alt="image-20230407164648736" style="zoom:80%;"><p>一顿操作，注册完毕后，进入你的主页</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071647649.png" alt="image-20230407164710504" style="zoom:80%;"><h3 id="创建新的仓库" tabindex="-1">创建新的仓库 <a class="header-anchor" href="#创建新的仓库" aria-label="Permalink to &quot;创建新的仓库&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071647767.png" alt="image-20230407164732616" style="zoom:80%;"><p>输入仓库的相关信息</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071648530.png" alt="image-20230407164816408" style="zoom:80%;"><p>点击创建按钮，创建新的仓库。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071648474.png" alt="image-20230407164834361" style="zoom:80%;"><h3 id="本地仓库的基本操作指令" tabindex="-1">本地仓库的基本操作指令 <a class="header-anchor" href="#本地仓库的基本操作指令" aria-label="Permalink to &quot;本地仓库的基本操作指令&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># create a new repository on the command line**</span></span>
<span class="line"><span style="color:#82AAFF;">echo</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;"># git-study</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&gt;&gt;</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">README.md</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">init</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">README.md</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-m</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">first commit</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">branch</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-M</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">main</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">remote</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git@github.com:Aitiger-coffee/git-study.git</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-u</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">main</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># push an existing repository from the command line**</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">remote</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git@github.com:Aitiger-coffee/git-study.git</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">branch</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-M</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">main</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-u</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">main</span></span></code></pre></div><h3 id="ssh免密操作" tabindex="-1">SSH免密操作 <a class="header-anchor" href="#ssh免密操作" aria-label="Permalink to &quot;SSH免密操作&quot;">​</a></h3><blockquote><p>github支持两种同步方式“https”和“ssh”。如果使用https很简单基本不需要配置就可以使用，但是每次提交代码和下载代码时都需要输入用户名和密码。ssh模式比https模式的一个重要好处就是，每次push、pull、fetch等操作时，不用重复填写遍用户名密码。前提是你必须是这个项目的拥有者或者合作者，且配好了ssh key。</p></blockquote><h4 id="本地生成ssh密钥" tabindex="-1">本地生成SSH密钥 <a class="header-anchor" href="#本地生成ssh密钥" aria-label="Permalink to &quot;本地生成SSH密钥&quot;">​</a></h4><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># ssh-keygen -t rsa -C GitHub 账号</span></span>
<span class="line"><span style="color:#FFCB6B;">ssh-keygen</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-t</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rsa</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-C</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">1597374863</span><span style="color:#C3E88D;">@qq.com</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071712507.png" alt="image-20230407171218368" style="zoom:80%;"><h4 id="集成用户公钥" tabindex="-1">集成用户公钥 <a class="header-anchor" href="#集成用户公钥" aria-label="Permalink to &quot;集成用户公钥&quot;">​</a></h4><p>执行命令完成后,在window本地用户.ssh目录C:\Users\用户名.ssh下面生成如下名称的公钥和私钥:</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071713219.png" alt="image-20230407171336118" style="zoom:80%;"><p>按照操作步骤，将id_rsa.pub文件内容复制到GitHub仓库中</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071714733.png" alt="image-20230407171408600" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071714195.png" alt="image-20230407171430066" style="zoom:80%;"><p>点击Add按钮，增加SSH公钥信息</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071714238.png" alt="image-20230407171444129" style="zoom:80%;"><h3 id="设定全局用户" tabindex="-1">设定全局用户 <a class="header-anchor" href="#设定全局用户" aria-label="Permalink to &quot;设定全局用户&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--global</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">user.name</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">15811009164</span><span style="color:#89DDFF;">&#39;</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 这里的邮箱地址需要为GitHub网站的注册账号</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--global</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">user.email</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">15811009164@163.com</span><span style="color:#89DDFF;">&#39;</span></span></code></pre></div><h3 id="创建本地库以远程地址" tabindex="-1">创建本地库以远程地址 <a class="header-anchor" href="#创建本地库以远程地址" aria-label="Permalink to &quot;创建本地库以远程地址&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 初始化本地仓库</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">init</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 设置远程仓库</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">remote</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git@github.com:Aitiger-coffee/git-study.git</span></span></code></pre></div><h3 id="新增-提交本地仓库文件" tabindex="-1">新增，提交本地仓库文件 <a class="header-anchor" href="#新增-提交本地仓库文件" aria-label="Permalink to &quot;新增，提交本地仓库文件&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 新增文件</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">test.txt</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 提交文件</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">test.txt</span></span></code></pre></div><h3 id="推送到github远程仓库" tabindex="-1">推送到GitHub远程仓库 <a class="header-anchor" href="#推送到github远程仓库" aria-label="Permalink to &quot;推送到GitHub远程仓库&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 新增文件</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">test.txt</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 提交文件</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">test.txt</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 推送文件</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span></span></code></pre></div><h3 id="查看github远程仓库" tabindex="-1">查看GitHub远程仓库 <a class="header-anchor" href="#查看github远程仓库" aria-label="Permalink to &quot;查看GitHub远程仓库&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071926767.png" alt="image-20230407192623654" style="zoom:80%;"><h3 id="增加合作伙伴" tabindex="-1">增加合作伙伴 <a class="header-anchor" href="#增加合作伙伴" aria-label="Permalink to &quot;增加合作伙伴&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071926246.png" alt="image-20230407192651139" style="zoom:80%;"><p>选择合作账号,发出合作申请</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071927199.png" alt="image-20230407192746090" style="zoom:80%;"><h3 id="合作伙伴确认" tabindex="-1">合作伙伴确认 <a class="header-anchor" href="#合作伙伴确认" aria-label="Permalink to &quot;合作伙伴确认&quot;">​</a></h3><p>合作伙伴收到确认后，点击Join按钮继续</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071928001.png" alt="image-20230407192801898" style="zoom:80%;"><p>点击Accept Invitation按钮，进行确认</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071928981.png" alt="image-20230407192819874" style="zoom:80%;"><p>此时已经可以合作开发了。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071929144.png" alt="image-20230407192906030" style="zoom:80%;"><h3 id="远程仓库fork操作" tabindex="-1">远程仓库fork操作 <a class="header-anchor" href="#远程仓库fork操作" aria-label="Permalink to &quot;远程仓库fork操作&quot;">​</a></h3><blockquote><p>如果项目存在大量合作伙伴，对于版本库的管理明显是一个特别大的风险，所以如果不想要选择大量的合作伙伴，但依然有人想要对项目代码进行维护，更新和扩展的话，此时，我们就可以使用fork功能。Forking 工作流是以 Github 为代表的一种代码协作方式，开发者通过克隆（fork）源仓库进行编写代码，一旦完成会发起 pull request，源仓库作者可以选择是否接受该 PR。</p></blockquote><p>随便找一个Github 开源项目：<a href="https://github.com/smileArchitect/JavaMap" target="_blank" rel="noreferrer">https://github.com/smileArchitect/JavaMap</a></p><p>右上角有三个按钮：Watch，Star，Fork</p><blockquote><p><code>Watch</code> 是关注的意思，一旦你点击了之后，该项目有任何改动都会第一时间通知到你；</p><p><code>Star</code> 类似于点赞的意思，多给开源项目点个赞，鼓励一下作者；</p><p><code>Fork</code> 本意是分叉，实际上是克隆的意思，点了之后会将该项目拷贝一份到自己的 github 远程仓库中。</p></blockquote><p><img src="https://mmbiz.qpic.cn/mmbiz_png/RXvHpViaz3EqhgtTib3HWYNO4rjQUicgnaMGM1Pm8sGvmCkUpaibbuL68N9pNb8mgd1jqDibicCHxXDZTmXs8Flcib9Mg/640?wx_fmt=png&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="图片"></p><blockquote><p>在本地执行 <code>git clone</code> 命令将代码克隆到本地，一顿修改操作后提交代码并 <code>push</code>到个人远程仓库中，然后在界面上发起 <code>pull request</code>，项目的原作者会看到你提交的 <code>PR</code>，根据提交的质量作者可以选择接受或拒绝。</p></blockquote><p>Github 工作流程</p><img src="https://mmbiz.qpic.cn/mmbiz_png/RXvHpViaz3EqhgtTib3HWYNO4rjQUicgnaMR1t2teG23V3wCFNJxDedzP8kIrAWnnPHkzkQXD9hRsp4mPrewpibzOQ/640?wx_fmt=png&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" alt="图片" style="zoom:80%;"><p>Forking 工作流非常适合于Github 开源项目，任何开发者都可以通过<code>fork + pull request</code> 向项目中贡献代码</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071930472.png" alt="image-20230407193005368" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071931670.png" alt="image-20230407193121556" style="zoom:80%;"><p>点击Create fork按钮即可</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071932870.png" alt="image-20230407193206763" style="zoom:80%;"><blockquote><p>这样就等同于创建了一个自己的远程仓库。但是这个远程仓库等同于是一个分支远程仓库，你可以随便操作，并不会影响源仓库，但是如果你的修改，更新想要融合到源仓库中，就需要提交申请了。</p></blockquote><p>我们这里首先将文件改一下。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071932251.png" alt="image-20230407193244136" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071932754.png" alt="image-20230407193256652" style="zoom:80%;"><p>发送提交申请</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071933903.png" alt="image-20230407193315797" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071933508.png" alt="image-20230407193337383" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071934952.png" alt="image-20230407193400825" style="zoom:80%;"><p>合并修改请求</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071934424.png" alt="image-20230407193456313" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071935951.png" alt="image-20230407193510834" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071935408.png" alt="image-20230407193532292" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071935006.png" alt="image-20230407193549893" style="zoom:80%;"><p>修改请求确认</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071936309.png" alt="image-20230407193624197" style="zoom:80%;"><h2 id="gitee集成" tabindex="-1">Gitee集成 <a class="header-anchor" href="#gitee集成" aria-label="Permalink to &quot;Gitee集成&quot;">​</a></h2><blockquote><p>相对于GitHub来讲，由于网络的原因，我们在连接时不是很稳定，所以我们在采用第三方远程仓库时，也可以选择国内的Gitee平台。</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071953396.png" alt="image-20230407195358241" style="zoom:80%;"><h3 id="注册网站会员-1" tabindex="-1">注册网站会员 <a class="header-anchor" href="#注册网站会员-1" aria-label="Permalink to &quot;注册网站会员&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071954605.png" alt="image-20230407195417424" style="zoom:80%;"><h3 id="用户中心" tabindex="-1">用户中心 <a class="header-anchor" href="#用户中心" aria-label="Permalink to &quot;用户中心&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071954449.png" alt="image-20230407195451322" style="zoom:80%;"><h3 id="创建远程仓库" tabindex="-1">创建远程仓库 <a class="header-anchor" href="#创建远程仓库" aria-label="Permalink to &quot;创建远程仓库&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071955607.png" alt="image-20230407195508490" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071955237.png" alt="image-20230407195526126" style="zoom:80%;"><h3 id="远程仓库操作指令" tabindex="-1">远程仓库操作指令 <a class="header-anchor" href="#远程仓库操作指令" aria-label="Permalink to &quot;远程仓库操作指令&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># Git全局设置，修改成自己的信息</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--global</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">user.name</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">Aitiger</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">config</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--global</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">user.email</span><span style="color:#A6ACCD;"> [</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">12252591+aitiger@user.noreply.gitee.com</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;">]</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 创建git仓库，基本操作指令和其他远程仓库一致</span></span>
<span class="line"><span style="color:#FFCB6B;">mkdir</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git-study</span></span>
<span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git-study</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">init</span><span style="color:#A6ACCD;"> </span></span>
<span class="line"><span style="color:#FFCB6B;">touch</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">README.md</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">README.md</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">commit</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-m</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">first commit</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">remote</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git@gitee.com:aitiger/git-study.git</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-u</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">master</span><span style="color:#89DDFF;">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 已有仓库</span></span>
<span class="line"><span style="color:#82AAFF;">cd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">existing_git_repo</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">remote</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git@gitee.com:aitiger/git-study.git</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-u</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">master</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><h3 id="配置ssh免密登录" tabindex="-1">配置SSH免密登录 <a class="header-anchor" href="#配置ssh免密登录" aria-label="Permalink to &quot;配置SSH免密登录&quot;">​</a></h3><h4 id="本地生成ssh密钥-1" tabindex="-1">本地生成SSH密钥 <a class="header-anchor" href="#本地生成ssh密钥-1" aria-label="Permalink to &quot;本地生成SSH密钥&quot;">​</a></h4><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># ssh-keygen -t rsa -C Gitee账号</span></span>
<span class="line"><span style="color:#FFCB6B;">ssh-keygen</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-t</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rsa</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-C</span><span style="color:#A6ACCD;"> </span><span style="color:#F78C6C;">12252591</span><span style="color:#C3E88D;">+aitiger@user.noreply.gitee.com</span></span>
<span class="line"><span style="color:#FFCB6B;">ssh-keygen</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-t</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ed25519</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-C</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">1597374863@qq.com</span><span style="color:#89DDFF;">&quot;</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211022100962.png" alt="image-20221102210017843" style="zoom:80%;"><h4 id="集成用户公钥-1" tabindex="-1">集成用户公钥 <a class="header-anchor" href="#集成用户公钥-1" aria-label="Permalink to &quot;集成用户公钥&quot;">​</a></h4><p>执行命令完成后,在window本地用户.ssh目录C:\Users\用户名.ssh下面生成如下名称的公钥和私钥:</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071956123.png" alt="image-20230407195658016" style="zoom:80%;"><p>Linux设置账户共公钥，获取公钥：</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">cat</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">~/.ssh/id_rsa.pub</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211022100669.png" alt="image-20221102210041586" style="zoom:80%;"><p>按照操作步骤，将id_rsa.pub文件内容复制到Gitee仓库中</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071957863.png" alt="image-20230407195732715" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071957164.png" alt="image-20230407195747058" style="zoom:80%;"><p>验证是否配置成功</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">ssh</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-T</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git@gitee.com</span></span></code></pre></div><p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211022101564.png" alt="image-20221102210106473"></p><p>添加并上传远程仓库（创建仓库时会有提示的）</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">remote</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">https://gitee.com/sure-s-renshuo/typora-img.git</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">push</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-u</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">origin</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">master</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img/image-20210930190101577.png" alt="image-20210930190101577" style="zoom:67%;"><h3 id="管理远程仓库" tabindex="-1">管理远程仓库 <a class="header-anchor" href="#管理远程仓库" aria-label="Permalink to &quot;管理远程仓库&quot;">​</a></h3><blockquote><p>可以对远程仓库进行删除、清空代码、查看仓库状态等操作。</p><p>进入步骤：点击头像、进入设置。点击数据管理的 “仓库信息管理”</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img/image-20211001155329489.png" alt="image-20211001155329489" style="zoom:67%;"><p>点击进入对应仓库的设置</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img/image-20211001155454305.png" alt="image-20211001155454305" style="zoom:67%;"><p>可以看到进行仓库管理了</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img/image-20211001155552723.png" alt="image-20211001155552723" style="zoom:50%;"><h3 id="多用户协作" tabindex="-1">多用户协作 <a class="header-anchor" href="#多用户协作" aria-label="Permalink to &quot;多用户协作&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072002683.png" alt="image-20230407200203570" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072002768.png" alt="image-20230407200215657" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072002201.png" alt="image-20230407200230070" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072002783.png" alt="image-20230407200242682" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072002680.png" alt="image-20230407200255571" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072003940.png" alt="image-20230407200313820" style="zoom:80%;"><h2 id="gitlab集成" tabindex="-1">GitLab集成 <a class="header-anchor" href="#gitlab集成" aria-label="Permalink to &quot;GitLab集成&quot;">​</a></h2><blockquote><p>前面给大家讲解的都是如何使用第三方代码托管平台来管理咱们的代码库。那么我们自己搭建一个这样的平台行不行呢？其实咱们之前已经用Git软件搭建了一个远程版本库，但是功能相对来讲，比较单一，而且操作起来也不像GitHub, Gitee平台那样更加人性化，所以我们这里介绍一个GitLab软件，用于搭建自己的代码托管平台。</p></blockquote><h3 id="gitlab介绍" tabindex="-1">GitLab介绍 <a class="header-anchor" href="#gitlab介绍" aria-label="Permalink to &quot;GitLab介绍&quot;">​</a></h3><blockquote><p>GitLab是由GitLabInc开发，使用MIT许可证的基于网络的Git仓库管理工具，且具有wiki和issue跟踪功能。使用Git作为代码管理工具，并在此基础上搭建起来的Web服务。</p></blockquote><blockquote><p>GitLib由乌克兰程序员DmitriyZaporozhets和ValerySizov开发，它使用Ruby语言写成。后来，一些部分用Go语言重写。GitLab被IBM，Sony，JulichResearchCenter，NASA，Alibab，Invincea，O&#39;ReillyMedia，Leibniz-Rechenzentrum(LRZ)，CERN，SpaceX等组织使用。</p></blockquote><blockquote><p>注意：gitlab相当占用内存，不用就停了吧</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072004545.png" alt="image-20230407200415407" style="zoom:80%;"><h3 id="gitlab软件下载" tabindex="-1">GitLab软件下载 <a class="header-anchor" href="#gitlab软件下载" aria-label="Permalink to &quot;GitLab软件下载&quot;">​</a></h3><p>官网地址：<a href="https://about.gitlab.com/" target="_blank" rel="noreferrer">https://about.gitlab.com/</a></p><p>安装地址：<a href="https://about.gitlab.com/install/#ubuntu" target="_blank" rel="noreferrer">https://about.gitlab.com/install/#ubuntu</a></p><p>这里我们可以根据个人情况，选择下载不同版本的软件：</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072004818.png" alt="image-20230407200439689" style="zoom:80%;"><p>我们这里主要是教学，所以下载使用社区版(CE)即可</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072004881.png" alt="image-20230407200455775" style="zoom:80%;"><p>这里我们选择下载适用CentOS 7系统的版本</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072005548.png" alt="image-20230407200510439" style="zoom:80%;"><p>下载地址：<a href="https://packages.gitlab.com/gitlab/gitlab-ce" target="_blank" rel="noreferrer">https://packages.gitlab.com/gitlab/gitlab-ce</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072005310.png" alt="image-20230407200531167" style="zoom:80%;"><p>如果下载不了，或下载比较慢，可以根据提示在在linux系统中直接采用wget指令下载</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072005317.png" alt="image-20230407200547194" style="zoom:80%;"><h3 id="gitlab安装" tabindex="-1">GitLab安装 <a class="header-anchor" href="#gitlab安装" aria-label="Permalink to &quot;GitLab安装&quot;">​</a></h3><h4 id="修改hosts" tabindex="-1">修改HOSTS <a class="header-anchor" href="#修改hosts" aria-label="Permalink to &quot;修改HOSTS&quot;">​</a></h4><p>win：C:\Windows\System32\drivers\etc\HOSTS，修改完成之后ping linux1即可</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 新增如下</span></span>
<span class="line"><span style="color:#FFCB6B;">221.238.82.216</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">linux1</span></span></code></pre></div><p>linux：/etc/hosts，修改完成之后ping linux1即可</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">vi</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/etc/hosts</span></span>
<span class="line"><span style="color:#FFCB6B;">127.0.0.1</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">linux1</span></span></code></pre></div><h4 id="centsos安装gitlab" tabindex="-1">centsos安装GitLab <a class="header-anchor" href="#centsos安装gitlab" aria-label="Permalink to &quot;centsos安装GitLab&quot;">​</a></h4><p>直接采用下载的RPM软件包安装即可</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">rpm</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-ivh</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">/opt/module/software/gitlab-ce-15.7.0-ce.0.el7.x86_64.rpm</span></span></code></pre></div><p>安装配置依赖项</p><blockquote><p>在CentOS 7上，下面的命令也会在系统防火墙中打开HTTP、HTTPS和SSH访问。这是一个可选步骤，如果您打算仅从本地网络访问极狐GitLab，则可以跳过它</p></blockquote><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">yum</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">install</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-y</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">policycoreutils-python</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">openssh-server</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">perl</span></span>
<span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">enable</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">sshd</span></span>
<span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">start</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">sshd</span></span>
<span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">firewall-cmd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--permanent</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--add-service=http</span></span>
<span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">firewall-cmd</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--permanent</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">--add-service=https</span></span>
<span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reload</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">firewalld</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 为了演示方便，我们也可以直接关闭防火墙</span></span>
<span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">systemctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">stop</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">firewalld</span></span></code></pre></div><p>初始化GitLab</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 配置软件镜像</span></span>
<span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-fsSL</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">https://packages.gitlab.cn/repository/raw/scripts/setup.sh</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">/bin/bash</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 安装，注意https://后面跟虚拟机IP或者由IP指向的地址</span></span>
<span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">EXTERNAL_URL=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">https://linux1</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">yum</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">install</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-y</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">gitlab-ce</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 初始化</span></span>
<span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">gitlab-ctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">reconfigure</span></span></code></pre></div><h4 id="ubuntu安装gitlab" tabindex="-1">ubuntu安装Gitlab <a class="header-anchor" href="#ubuntu安装gitlab" aria-label="Permalink to &quot;ubuntu安装Gitlab&quot;">​</a></h4><p>安装和配置必要的依赖项</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">apt-get</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">update</span></span>
<span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">apt-get</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">install</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-y</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">openssh-server</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">ca-certificates</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">tzdata</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">perl</span></span></code></pre></div><p>安装 Postfix（或 Sendmail）以发送通知电子邮件。如果你想要使用其他解决方案发送电子邮件，请跳过此步骤</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">apt-get</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">install</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">-y</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">postfix</span></span></code></pre></div><p>在 Postfix 安装期间，可能会出现配置屏幕。选择 “互联网站点”，然后按回车键。将服务器的外部 DNS 用于 “邮件名称”，然后按回车键。如果出现其他屏幕，请继续 按回车键接受默认值。</p><p>添加 GitLab 包存储库并安装包</p><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#FFCB6B;">curl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">|</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">bash</span></span>
<span class="line"><span style="color:#FFCB6B;">sudo</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">EXTERNAL_URL=</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">https://202.113.69.19</span><span style="color:#89DDFF;">&quot;</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">apt-get</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">install</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">gitlab-ee</span></span></code></pre></div><h3 id="启动停止gitlab" tabindex="-1">启动停止GitLab <a class="header-anchor" href="#启动停止gitlab" aria-label="Permalink to &quot;启动停止GitLab&quot;">​</a></h3><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 启动</span></span>
<span class="line"><span style="color:#FFCB6B;">gitlab-ctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">start</span></span>
<span class="line"><span style="color:#676E95;font-style:italic;"># 停止</span></span>
<span class="line"><span style="color:#FFCB6B;">gitlab-ctl</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">stop</span></span></code></pre></div><h3 id="访问gitlab" tabindex="-1">访问GitLab <a class="header-anchor" href="#访问gitlab" aria-label="Permalink to &quot;访问GitLab&quot;">​</a></h3><p>使用浏览器访问GitLab，输入网址：<a href="http://linux1/users/sign_in" target="_blank" rel="noreferrer">http://linux1/users/sign_in</a></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072011215.png" alt="image-20230407201100099" style="zoom:80%;"><p>初始化时，软件会提供默认管理员账户：root,但是密码是随机生成的。</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072011970.png" alt="image-20230407201129856" style="zoom:80%;"><p>根据提示，在/etc/gitlab/initial_root_password文件中查找密码</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072011437.png" alt="image-20230407201148326" style="zoom:80%;"><p>输入账号，密码，进入系统</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072012930.png" alt="image-20230407201249811" style="zoom:80%;"><h4 id="修改密码" tabindex="-1">修改密码 <a class="header-anchor" href="#修改密码" aria-label="Permalink to &quot;修改密码&quot;">​</a></h4><p>默认的密码是随机的，且不容易记忆，还会在系统初始化后24小时被删除，所以需要先修改一下密码</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072014925.png" alt="image-20230407201400807" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072014935.png" alt="image-20230407201414816" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072014408.png" alt="image-20230407201429296" style="zoom:80%;"><h4 id="创建项目" tabindex="-1">创建项目 <a class="header-anchor" href="#创建项目" aria-label="Permalink to &quot;创建项目&quot;">​</a></h4><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072014928.png" alt="image-20230407201450793" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072035584.png" alt="image-20230407203515442" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072035032.png" alt="image-20230407203534895" style="zoom:80%;"><h3 id="集成idea" tabindex="-1">集成IDEA <a class="header-anchor" href="#集成idea" aria-label="Permalink to &quot;集成IDEA&quot;">​</a></h3><h4 id="安装gitlab插件" tabindex="-1">安装GitLab插件 <a class="header-anchor" href="#安装gitlab插件" aria-label="Permalink to &quot;安装GitLab插件&quot;">​</a></h4><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072036286.png" alt="image-20230407203605147" style="zoom:80%;"><h4 id="配置gitlab" tabindex="-1">配置GitLab <a class="header-anchor" href="#配置gitlab" aria-label="Permalink to &quot;配置GitLab&quot;">​</a></h4><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072036537.png" alt="image-20230407203621392" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072036432.png" alt="image-20230407203632315" style="zoom:80%;"><h4 id="创建新项目" tabindex="-1">创建新项目 <a class="header-anchor" href="#创建新项目" aria-label="Permalink to &quot;创建新项目&quot;">​</a></h4><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072036550.png" alt="image-20230407203646444" style="zoom:80%;"><h4 id="创建本地仓库-1" tabindex="-1">创建本地仓库 <a class="header-anchor" href="#创建本地仓库-1" aria-label="Permalink to &quot;创建本地仓库&quot;">​</a></h4><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072037063.png" alt="image-20230407203659939" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072037481.png" alt="image-20230407203714366" style="zoom:80%;"><h4 id="创建新代码" tabindex="-1">创建新代码 <a class="header-anchor" href="#创建新代码" aria-label="Permalink to &quot;创建新代码&quot;">​</a></h4><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072037318.png" alt="image-20230407203727211" style="zoom:80%;"><h4 id="提交文件-1" tabindex="-1">提交文件 <a class="header-anchor" href="#提交文件-1" aria-label="Permalink to &quot;提交文件&quot;">​</a></h4><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072037474.png" alt="image-20230407203745359" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072038293.png" alt="image-20230407203800173" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072038325.png" alt="image-20230407203813222" style="zoom:80%;"><h4 id="推送远程库" tabindex="-1">推送远程库 <a class="header-anchor" href="#推送远程库" aria-label="Permalink to &quot;推送远程库&quot;">​</a></h4><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072055267.png" alt="image-20230407205537137" style="zoom:80%;"><h4 id="配置远程库" tabindex="-1">配置远程库 <a class="header-anchor" href="#配置远程库" aria-label="Permalink to &quot;配置远程库&quot;">​</a></h4><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072055319.png" alt="image-20230407205555206" style="zoom:80%;"><h4 id="推送文件-1" tabindex="-1">推送文件 <a class="header-anchor" href="#推送文件-1" aria-label="Permalink to &quot;推送文件&quot;">​</a></h4><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072056279.png" alt="image-20230407205611087" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072056069.png" alt="image-20230407205621935" style="zoom:80%;"><h4 id="合并提交请求" tabindex="-1">合并提交请求 <a class="header-anchor" href="#合并提交请求" aria-label="Permalink to &quot;合并提交请求&quot;">​</a></h4><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072057292.png" alt="image-20230407205724155" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072057084.png" alt="image-20230407205738970" style="zoom:80%;"><p>合并</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072058794.png" alt="image-20230407205808670" style="zoom:80%;"><p>确认文件提交</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072058138.png" alt="image-20230407205843014" style="zoom:80%;"><h1 id="集成idea-1" tabindex="-1">集成IDEA <a class="header-anchor" href="#集成idea-1" aria-label="Permalink to &quot;集成IDEA&quot;">​</a></h1><h2 id="配置环境" tabindex="-1">配置环境 <a class="header-anchor" href="#配置环境" aria-label="Permalink to &quot;配置环境&quot;">​</a></h2><blockquote><p>实际的开发中，代码都是采用IDE进行开发，所以我们这里介绍一下IDEA软件是如何集成GitHub远程仓库进行代码版本控制的。这里采用的IDEA版本为2022.2.1,其他版本的IDEA软件会略有差别</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071936778.png" alt="image-20230407193659679" style="zoom:80%;"><h3 id="配置git软件" tabindex="-1">配置Git软件 <a class="header-anchor" href="#配置git软件" aria-label="Permalink to &quot;配置Git软件&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071937334.png" alt="image-20230407193715200" style="zoom:80%;"><h3 id="配置账号" tabindex="-1">配置账号 <a class="header-anchor" href="#配置账号" aria-label="Permalink to &quot;配置账号&quot;">​</a></h3><p>Gitee和Github都是一样的操作</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071937582.png" alt="image-20230407193742451" style="zoom:80%;"><p>继续点授权按钮，没弹出来就切换默认浏览器为EDGE</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071940898.png" alt="image-20230407194053800" style="zoom:80%;"><p>继续点击授权按钮</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071941250.png" alt="image-20230407194106129" style="zoom:80%;"><p>输入GitHub账号密码</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071941999.png" alt="image-20230407194137898" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304082141424.png" alt="image-20230408214101317" style="zoom:80.3%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304082140093.png" alt="image-20230408214043903" style="zoom:80%;"><h3 id="安装插件" tabindex="-1">安装插件 <a class="header-anchor" href="#安装插件" aria-label="Permalink to &quot;安装插件&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071958244.png" alt="image-20230407195826121" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304082142399.png" alt="image-20230408214218263" style="zoom:80%;"><h2 id="创建项目-1" tabindex="-1">创建项目 <a class="header-anchor" href="#创建项目-1" aria-label="Permalink to &quot;创建项目&quot;">​</a></h2><h3 id="创建项目-2" tabindex="-1">创建项目 <a class="header-anchor" href="#创建项目-2" aria-label="Permalink to &quot;创建项目&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071942394.png" alt="image-20230407194214268" style="zoom:80%;"><h3 id="添加项目代码" tabindex="-1">添加项目代码 <a class="header-anchor" href="#添加项目代码" aria-label="Permalink to &quot;添加项目代码&quot;">​</a></h3><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071942021.png" alt="image-20230407194231924" style="zoom:80%;"><h2 id="初始化本地仓库" tabindex="-1">初始化本地仓库 <a class="header-anchor" href="#初始化本地仓库" aria-label="Permalink to &quot;初始化本地仓库&quot;">​</a></h2><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 方式一：直接进命令行输入，即可</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">init</span></span></code></pre></div><p>方式二</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071942907.png" alt="image-20230407194249805" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071943106.png" alt="image-20230407194315007" style="zoom:80%;"><p>方式三</p><p>在IDEA中通过如下操作可以在本地初始化一个本地仓库，其实底层就是执行的 git init 命令。操作过程如下：</p><p>1）依次选择菜单【VCS】---【Import into Version Control】---【Create Git Repository】</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913322.png" alt="image-20210926153806414" style="zoom:80%;"><p>2）在弹出的【Create Git Repository】对话框中选择当前项目根目录，点击【OK】按钮：</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913323.png" alt="image-20210926154201744" style="zoom:80%;"><p>操作完成后可以看到当前项目根目录下出现了.git隐藏目录：</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010918532.png" alt="image-20221101091825463" style="zoom:80%;"><p>操作完成后可以在IDEA的工具栏中看到Git的相关操作图标：<img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010918261.png" alt="image-20221101091843201" style="zoom:80%;"></p><h2 id="克隆远程仓库-1" tabindex="-1">克隆远程仓库 <a class="header-anchor" href="#克隆远程仓库-1" aria-label="Permalink to &quot;克隆远程仓库&quot;">​</a></h2><p>在IDEA中从远程仓库克隆本质就是执行的 git clone 命令，具体操作过程如下：</p><p>1）在IDEA开始窗口中点击【Get from Version Control】</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913327.png" alt="image-20210926155434202" style="zoom:80%;"><p>2）在弹出的【Get from Version Control】窗口中输入远程仓库的URL地址和对应的本地仓库存放目录，点击【Clone】按钮进行仓库克隆操作</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913332.png" alt="image-20210926155750107" style="zoom:80%;"><h2 id="本地仓库操作" tabindex="-1">本地仓库操作 <a class="header-anchor" href="#本地仓库操作" aria-label="Permalink to &quot;本地仓库操作&quot;">​</a></h2><p>本地仓库操作：</p><ul><li>将文件加入暂存区，本质就是执行 git add 命令</li><li>将暂存区的文件提交到版本库，本质就是执行 git commit 命令</li><li>查看日志，本质就是执行 git log 命令</li></ul><h3 id="将文件加入暂存区" tabindex="-1">将文件加入暂存区 <a class="header-anchor" href="#将文件加入暂存区" aria-label="Permalink to &quot;将文件加入暂存区&quot;">​</a></h3><p>当在Git工作区新增文件或者对已有文件修改后，就需要将文件的修改加入暂存区，具体操作如下：</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913839.png" alt="image-20210926162515597" style="zoom:80%;"><h3 id="提交本地版本库" tabindex="-1">提交本地版本库 <a class="header-anchor" href="#提交本地版本库" aria-label="Permalink to &quot;提交本地版本库&quot;">​</a></h3><blockquote><p>将暂存区文件提交到版本库，可以选择一个文件进行提交，也可以选择整个项目提交多个文件。在IEDA中对文件的提交进行了简化操作，也就是如果文件修改后，无需再加入暂存区，可以直接提交。</p></blockquote><blockquote><p>由于提交操作属于高频操作，所以为了进一步方便操作，在IDEA的工具栏中提供了提交操作的快捷按钮：<img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913197.png" alt="image-20210926163535277"></p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071943749.png" alt="image-20230407194354623" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071944683.png" alt="image-20230407194414576" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071944436.png" alt="image-20230407194432303" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071944687.png" alt="image-20230407194450576" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071945158.png" alt="image-20230407194507056" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071945697.png" alt="image-20230407194519593" style="zoom:80%;"><h3 id="查看提交历史" tabindex="-1">查看提交历史 <a class="header-anchor" href="#查看提交历史" aria-label="Permalink to &quot;查看提交历史&quot;">​</a></h3><blockquote><p>查看日志，<strong>既可以查看整个仓库的提交日志，也可以查看某个文件的提交日志</strong>。</p></blockquote><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071949705.png" alt="image-20230407194924589" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071949342.png" alt="image-20230407194952204" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071950485.png" alt="image-20230407195031360" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071951553.png" alt="image-20230407195115424" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211030910639.png" alt="image-20221103091019549" style="zoom:80%;"><p>2）查看某个文件的提交日志</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913524.png" alt="image-20210926164210056" style="zoom:67%;"><p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913554.png" alt="image-20210926164233935"></p><h2 id="远程仓库操作" tabindex="-1">远程仓库操作 <a class="header-anchor" href="#远程仓库操作" aria-label="Permalink to &quot;远程仓库操作&quot;">​</a></h2><blockquote><ul><li>查看远程仓库，本质就是执行 git remote 命令</li><li>添加远程仓库，本质就是执行 git remote add 命令</li><li>推送至远程仓库，本质就是执行 git push 命令</li><li>从远程仓库拉取，本质就是执行 git pull 命令</li></ul></blockquote><h3 id="查看远程仓库-2" tabindex="-1">查看远程仓库 <a class="header-anchor" href="#查看远程仓库-2" aria-label="Permalink to &quot;查看远程仓库&quot;">​</a></h3><p>操作过程如下：</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913889.png" alt="image-20210926165935756" style="zoom:80%;"><p>在弹出的【Git Remotes】窗口中可以看到配置的远程仓库：</p><p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913031.png" alt="image-20210926170143160"></p><h3 id="添加远程仓库-1" tabindex="-1">添加远程仓库 <a class="header-anchor" href="#添加远程仓库-1" aria-label="Permalink to &quot;添加远程仓库&quot;">​</a></h3><p>一个本地仓库可以配置多个远程仓库，在【Git Remotes】窗口中点击【+】来添加一个新的远程仓库：</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913066.png" alt="image-20210926170653126" style="zoom:80%;"><h3 id="推送至远程仓库-1" tabindex="-1">推送至远程仓库 <a class="header-anchor" href="#推送至远程仓库-1" aria-label="Permalink to &quot;推送至远程仓库&quot;">​</a></h3><p>可以通过如下操作将本地仓库文件推送至远程仓库：</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071945150.png" alt="image-20230407194534049" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071945337.png" alt="image-20230407194554213" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071946442.png" alt="image-20230407194617342" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071947519.png" alt="image-20230407194733414" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071948266.png" alt="image-20230407194801154" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071948275.png" alt="image-20230407194820153" style="zoom:80%;"><p>在弹出的【Push Commits】窗口中可以看到本次推送的文件，点击【Push】按钮即可推送至远程仓库：</p><p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913294.png" alt="image-20210926171058705"></p><p>由于推送至远程仓库操作属于高频操作，所以可以通过IDEA工具栏中的提交快捷按钮同时完成提交和推送：</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010939698.png" alt="image-20221101093914588" style="zoom:80%;"><p>点击【Commit and Push...】按钮同时完成提交和推送操作</p><h3 id="从远程仓库拉取" tabindex="-1">从远程仓库拉取 <a class="header-anchor" href="#从远程仓库拉取" aria-label="Permalink to &quot;从远程仓库拉取&quot;">​</a></h3><p>可以通过如下操作从远程仓库拉取：</p><p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913534.png" alt="image-20210926171646041"></p><p>由于从远程仓库拉取文件属于高频操作，所以在IDEA的工具栏中提供了对应的快捷按钮：<img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913658.png" alt="image-20210926171919288"></p><p>在弹出的【Update Project】窗口中点击【OK】：</p><p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913685.png" alt="image-20210926171950911"></p><h3 id="拉取代码冲突" tabindex="-1">拉取代码冲突 <a class="header-anchor" href="#拉取代码冲突" aria-label="Permalink to &quot;拉取代码冲突&quot;">​</a></h3><p>上面我们提了分支合并，可以从本地分支合并，也可以从远程仓库合并，一般两个并行开发的分支合并都是会有冲突，Idea中合并冲突是非常方便的。在合并过程中发生了冲突，Idea会提示冲突，选择<code>Merge</code></p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.6.30/202207271000786.png" alt="image-20220727100034671" style="zoom:50%;"><p>Idea提供了三个分栏，我们可以点击箭头，很方便地处理冲突</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.6.30/202207271000123.png" alt="image-20220727100053001" style="zoom:67%;"><p>如果合并时没有处理，也可以在<code>Version Controller</code>中处理</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.6.30/202207271001210.png" alt="image-20220727100144094" style="zoom:67%;"><h4 id="增加远程地址" tabindex="-1">增加远程地址 <a class="header-anchor" href="#增加远程地址" aria-label="Permalink to &quot;增加远程地址&quot;">​</a></h4><div class="language-sh"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#676E95;font-style:italic;"># 增加远程地址</span></span>
<span class="line"><span style="color:#FFCB6B;">git</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">remote</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">add</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">gitee-study</span><span style="color:#A6ACCD;"> </span><span style="color:#C3E88D;">git@gitee.com:aitiger/git-study.git</span></span></code></pre></div><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072000450.png" alt="image-20230407200025344" style="zoom:80%;"><h4 id="提交本地代码" tabindex="-1">提交本地代码 <a class="header-anchor" href="#提交本地代码" aria-label="Permalink to &quot;提交本地代码&quot;">​</a></h4><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072000538.png" alt="image-20230407200045437" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072000851.png" alt="image-20230407200059735" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072001576.png" alt="image-20230407200118471" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304072001630.png" alt="image-20230407200140498" style="zoom:80%;"><h2 id="分支操作-2" tabindex="-1">分支操作 <a class="header-anchor" href="#分支操作-2" aria-label="Permalink to &quot;分支操作&quot;">​</a></h2><ul><li>查看分支，本质就是执行 git branch 命令</li><li>创建分支，本质就是执行 git branch 分支名 命令</li><li>切换分支，本质就是执行 git checkout 命令</li><li>将分支推送到远程仓库，本质就是执行 git push 命令</li><li>合并分支，本质就是执行 git merge 命令</li></ul><h3 id="分支图解⭐" tabindex="-1">分支图解⭐ <a class="header-anchor" href="#分支图解⭐" aria-label="Permalink to &quot;分支图解⭐&quot;">​</a></h3><p>分支切换/比较/合并/重命名/删除，在Idea中这些功能的使用也常简单，点击分支，点击要操作的分支，可以看到</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.6.30/202207271004013.png" alt="image-20220727100431902" style="zoom:50%;"><h3 id="查看分支-1" tabindex="-1">查看分支 <a class="header-anchor" href="#查看分支-1" aria-label="Permalink to &quot;查看分支&quot;">​</a></h3><p>可以通过如下操作查看分支：</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913889.png" alt="image-20210926172752562" style="zoom:80%;"><p>在弹出的窗口中可以看到本地分支和远程分支：</p><p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913923.png" alt="image-20210926172903493"></p><p>由于分支操作属于高频操作，所以在IDEA的状态栏中提供了分支操作的快捷按钮：</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913953.png" alt="image-20210926173622605" style="zoom:80%;"><p>点击【master】快捷按钮即可弹出【Git Branches】分支窗口：</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913153.png" alt="image-20210926173744979" style="zoom:80%;"><h3 id="创建分支-2" tabindex="-1">创建分支 <a class="header-anchor" href="#创建分支-2" aria-label="Permalink to &quot;创建分支&quot;">​</a></h3><p>在【Git Branches】分支窗口中点击【New Branch】，弹出如下窗口：</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071951709.png" alt="image-20230407195130602" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071951657.png" alt="image-20230407195141552" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071951781.png" alt="image-20230407195154673" style="zoom:80%;"><h3 id="切换分支-2" tabindex="-1">切换分支 <a class="header-anchor" href="#切换分支-2" aria-label="Permalink to &quot;切换分支&quot;">​</a></h3><p>通过如下操作可以切换分支：</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913214.png" alt="image-20210926174358500" style="zoom:80%;"><h3 id="推送分支-1" tabindex="-1">推送分支 <a class="header-anchor" href="#推送分支-1" aria-label="Permalink to &quot;推送分支&quot;">​</a></h3><p>通过如下操作可以将分支推送到远程仓库：</p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071952320.png" alt="image-20230407195206209" style="zoom:80%;"><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2023.3.30/202304071952693.png" alt="image-20230407195221564" style="zoom:80%;"><p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913342.png" alt="image-20210926175004502"></p><h3 id="合并分支-2" tabindex="-1">合并分支 <a class="header-anchor" href="#合并分支-2" aria-label="Permalink to &quot;合并分支&quot;">​</a></h3><p>通过下面操作可以进行分支的合并：</p><p><img src="https://edu-8673.oss-cn-beijing.aliyuncs.com/img2022.12.30/202211010913374.png" alt="image-20210926175216197"></p></div></div></main><footer class="VPDocFooter" data-v-6b87e69f data-v-37656e44><!--[--><!--]--><!----><nav class="prev-next" data-v-37656e44><div class="pager" data-v-37656e44><a class="pager-link prev" href="/notebook/Mybatis&amp;MybatisPlus/JPA.html" data-v-37656e44><span class="desc" data-v-37656e44>Previous page</span><span class="title" data-v-37656e44>JPA</span></a></div><div class="pager" data-v-37656e44><a class="pager-link next" href="/notebook/5%E3%80%81%E8%BF%90%E7%BB%B4/Github.html" data-v-37656e44><span class="desc" data-v-37656e44>Next page</span><span class="title" data-v-37656e44>Github</span></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><!----><!--[--><!--]--></div></div>
    <script>window.__VP_HASH_MAP__=JSON.parse("{\"2、数据库_mysql_mysql面试_基础.md\":\"40da680a\",\"1、学前端_5、小程序_小程序项目.md\":\"60a1629b\",\"1、学前端_4、node_知识篇.md\":\"a7fb500e\",\"1、学前端_2、js_ts_es6 进阶.md\":\"6d07ba10\",\"1、学前端_3、vue_vue3_vue3进阶.md\":\"7ac622b4\",\"5、运维_jenkins.md\":\"929081f8\",\"1、学前端_2、js_ts_typescript.md\":\"875a4aa4\",\"2、数据库_mysql_mysql核心_设计.md\":\"7faf46d1\",\"2、数据库_mysql_mysql核心_基础.md\":\"d8e97f3e\",\"1、学前端_1、html_css_html基础.md\":\"7584d076\",\"1、学前端_5、专题篇_问题篇.md\":\"e893aaa2\",\"2、数据库_mysql_mysql面试_进阶.md\":\"f934806d\",\"3、springboot_运维_原理.md\":\"f4a39db6\",\"2、数据库_influxdb.md\":\"6e1711e1\",\"3、springboot_新特性.md\":\"cdf3e307\",\"mybatis_mybatisplus_jpa.md\":\"8e41681b\",\"1、学前端_5、小程序_小程序优化.md\":\"a2185198\",\"2、数据库_redis_redis基础.md\":\"856df0e0\",\"linux_实用脚本.md\":\"f2299dd5\",\"4、微服务_必备_分布式基础.md\":\"d49863d5\",\"2、数据库_redis_redis优化.md\":\"e66ae32f\",\"4、微服务_springsecurity_进阶篇.md\":\"235a8e9e\",\"5、运维_chatgpt.md\":\"10db3823\",\"2、数据库_mysql_分库分表.md\":\"e1c8a095\",\"start.md\":\"9bc1ff8d\",\"5、运维_github.md\":\"2ec6c735\",\"java学前端_css.md\":\"f11b47f0\",\"1、学前端_5、专题篇_知识篇.md\":\"a463ed8d\",\"linux_软件部署.md\":\"d6722925\",\"2、数据库_neo4j.md\":\"97ad22ac\",\"team.md\":\"ce467a6a\",\"nginx_实战篇.md\":\"7785486e\",\"index.md\":\"8c3ec167\",\"计算机基础_计算机网络_网络基础.md\":\"7a54a85d\",\"1、学前端_4、node_进阶篇.md\":\"60f6db69\",\"java_java集合.md\":\"a049b313\",\"1、学前端_3、vue_vue3_vue3高级.md\":\"614d1516\",\"1、学前端_5、小程序_微信小程序.md\":\"9a4be771\",\"5、运维_netty.md\":\"12ca0278\",\"2、数据库_mysql_mysql核心_运维.md\":\"83f97c16\",\"idea_vs code.md\":\"afdcb593\",\"java学前端_vue3_组件.md\":\"1086884e\",\"idea_chrome.md\":\"4a32afbc\",\"云原生_k8s.md\":\"db58e65a\",\"2、数据库_mysql_mysql核心_进阶.md\":\"61d16dff\",\"ssm_springbatch.md\":\"f799ab4a\",\"三高_分布式.md\":\"db1b8a1b\",\"2、数据库_elasticsearch_1、es基础.md\":\"04d17448\",\"linux_linux基础.md\":\"4b0bf394\",\"idea_idea插件.md\":\"fa86e45a\",\"可视化 _ 监控_可视化大屏.md\":\"004553bd\",\"2、数据库_mongodb_整合.md\":\"3c47d7f4\",\"4、微服务_springsecurity_基础篇.md\":\"534a3401\",\"4、微服务_进阶.md\":\"69095c58\",\"计算机基础_计算机基础_操作系统.md\":\"0f75d113\",\"可视化 _ 监控_zabbix.md\":\"71f2270e\",\"nginx_基础篇.md\":\"c7d8bb50\",\"1、学前端_4、node_项目实战.md\":\"bc5065b8\",\"2、数据库_redis_redis原理.md\":\"5cedf685\",\"可视化 _ 监控_监控基础.md\":\"ac56ce4d\",\"三高_高并发.md\":\"ea9ffc99\",\"2、数据库_redis_redis高级.md\":\"1d5872f6\",\"1、学前端_4、node_基础篇.md\":\"581cc13a\",\"2、数据库_mongodb_基础.md\":\"fb7a0a29\",\"idea_idea基础.md\":\"6f2f9638\",\"4、微服务_必备_sentinel.md\":\"2edfbf6c\",\"2、数据库_elasticsearch_3、es高级.md\":\"ef146606\",\"1、学前端_3、vue_vue3_vue3新语法.md\":\"8afd5409\",\"消息中间件_canal.md\":\"3949163c\",\"ssm_maven.md\":\"2c5e12ed\",\"4、微服务_springsecurity_高级篇.md\":\"882d3ff3\",\"linux_linux进阶.md\":\"188ef7b4\",\"计算机基础_设计模式_uml.md\":\"634ba256\",\"计算机基础_算法_leetcode.md\":\"77162fb9\",\"项目实战_小兔鲜_进阶篇1.md\":\"17c52c81\",\"1、学前端_2、js_ts_es6 基础.md\":\"fda3f18b\",\"项目实战_小兔鲜_进阶篇2.md\":\"a0f23006\",\"软件测试_测试基础.md\":\"8c1060cd\",\"2、数据库_redis_本地缓存.md\":\"00617fe6\",\"nginx_面试篇.md\":\"e3fb373a\",\"mybatis_mybatisplus_mybatis.md\":\"9239e0ad\",\"linux_shell.md\":\"ae53d83b\",\"2、数据库_mysql_mysql核心_优化.md\":\"36230425\",\"项目实战_项目推荐.md\":\"f9d97630\",\"mybatis_mybatisplus_mybatisplus.md\":\"0030fd35\",\"项目实战_百度地图_进阶篇.md\":\"c8b93267\",\"三高_高可用.md\":\"323840c5\",\"java_java新特性.md\":\"22abf56d\",\"软件测试_压力测试.md\":\"9ab44440\",\"java学前端_html_js.md\":\"e0fcd240\",\"2、数据库_redis_redis实战.md\":\"d6daeeab\",\"nginx_进阶篇.md\":\"e6b63195\",\"三高_秒杀.md\":\"3878bb64\",\"5、运维_git.md\":\"0264925c\",\"java_java进阶.md\":\"e79cb5b4\",\"并发 _ 多线程_基础篇.md\":\"7adbfac5\",\"项目实战_百度地图_基础篇.md\":\"8afa5954\",\"java学前端_react.md\":\"3ec827dd\",\"1、学前端_1、html_css_css基础.md\":\"01b56712\",\"项目实战_小兔鲜_基础篇.md\":\"646f5df5\",\"1、学前端_2、js_ts_js 基础.md\":\"cb13e36f\",\"可视化 _ 监控_监控进阶.md\":\"0cdbc292\",\"计算机基础_设计模式_基础篇.md\":\"51617287\",\"计算机基础_数据结构_基础篇.md\":\"b2bfd8d4\",\"项目实战_苍穹外卖_进阶篇.md\":\"48415e41\",\"ssm_spring.md\":\"ab514659\",\"消息中间件_rabbitmq.md\":\"45b1eb28\",\"1、学前端_1、html_css_网页进阶.md\":\"db998248\",\"消息中间件_kafka.md\":\"b747dabf\",\"云原生_docker.md\":\"983c7ba7\",\"4、微服务_必备_分布式锁.md\":\"5af1cf8d\",\"消息中间件_rocketmq.md\":\"d441da85\",\"项目实战_黑马头条_基础篇.md\":\"b05af3a6\",\"ssm_springmvc.md\":\"81b9714f\",\"项目实战_支付.md\":\"1d7407dd\",\"项目实战_黑马头条_进阶篇2.md\":\"bff0015b\",\"项目实战_黑马头条_进阶篇.md\":\"19f18388\",\"java学前端_vue2_组件.md\":\"58c6b1df\",\"3、springboot_基础篇.md\":\"529c66f4\",\"3、springboot_应用篇.md\":\"8b92aa61\",\"项目实战_黑马头条_高级篇.md\":\"227c08c1\",\"1、学前端_5、小程序_uniapp.md\":\"71a282b4\",\"项目实战_云尚办公_基础篇.md\":\"1fe188ba\",\"并发 _ 多线程_并发完善.md\":\"26619c46\",\"1、学前端_2、js_ts_js 进阶.md\":\"657dfb8f\",\"java_java高级.md\":\"23782d1a\",\"java_java基础.md\":\"86d67c77\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"VitePress\",\"description\":\"A VitePress site\",\"base\":\"/notebook/\",\"head\":[],\"appearance\":true,\"themeConfig\":{\"algolia\":{\"appId\":\"DW7O63I9IR\",\"apiKey\":\"f8ed758cdb288a8b06542bc35923c1a1\",\"indexName\":\"notebook\"},\"sidebar\":[{\"text\":\"Java\",\"collapsed\":true,\"items\":[{\"text\":\"Java基础\",\"link\":\"/Java/Java基础\"},{\"text\":\"Java新特性\",\"link\":\"/Java/Java新特性\"},{\"text\":\"Java进阶\",\"link\":\"/Java/Java进阶\"},{\"text\":\"Java集合\",\"link\":\"/Java/Java集合\"},{\"text\":\"Java高级\",\"link\":\"/Java/Java高级\"}]},{\"text\":\"Linux\",\"collapsed\":true,\"items\":[{\"text\":\"Linux基础\",\"link\":\"/Linux/Linux基础\"},{\"text\":\"Linux新特性\",\"link\":\"/Linux/Linux进阶\"},{\"text\":\"Shell脚本\",\"link\":\"/Linux/Shell\"},{\"text\":\"实用脚本\",\"link\":\"/Linux/实用脚本\"},{\"text\":\"软件部署\",\"link\":\"/Linux/软件部署\"}]},{\"text\":\"Nginx\",\"collapsed\":true,\"items\":[{\"text\":\"基础篇\",\"link\":\"/Nginx/基础篇\"},{\"text\":\"进阶篇\",\"link\":\"/Nginx/进阶篇\"},{\"text\":\"实战篇\",\"link\":\"/Nginx/实战篇\"},{\"text\":\"面试篇\",\"link\":\"/Nginx/面试篇\"}]},{\"text\":\"SSM\",\"collapsed\":true,\"items\":[{\"text\":\"Maven\",\"link\":\"/SSM/Maven\"},{\"text\":\"Spring\",\"link\":\"/SSM/Spring\"},{\"text\":\"SpringMVC\",\"link\":\"/SSM/SpringMVC\"},{\"text\":\"SpringBatch\",\"link\":\"/SSM/SpringBatch\"}]},{\"text\":\"SpringBoot\",\"collapsed\":true,\"items\":[{\"text\":\"基础篇\",\"link\":\"/3、SpringBoot/基础篇\"},{\"text\":\"应用篇\",\"link\":\"/3、SpringBoot/应用篇\"},{\"text\":\"新特性\",\"link\":\"/3、SpringBoot/新特性\"},{\"text\":\"运维&原理\",\"link\":\"/3、SpringBoot/运维&原理\"}]},{\"text\":\"SpringCloud\",\"collapsed\":true,\"items\":[{\"text\":\"SpringCloud\",\"link\":\"/4、微服务/进阶\"},{\"text\":\"Sentinel\",\"link\":\"/4、微服务/必备/Sentinel\"}]},{\"text\":\"SpringSecurity\",\"collapsed\":true,\"items\":[{\"text\":\"SpringSecurity基础篇\",\"link\":\"/4、微服务/SpringSecurity/基础篇\"},{\"text\":\"SpringSecurity进阶篇\",\"link\":\"/4、微服务/SpringSecurity/进阶篇\"},{\"text\":\"SpringSecurity高级篇\",\"link\":\"/4、微服务/SpringSecurity/高级篇\"}]},{\"text\":\"Mybatis & MybatisPlus\",\"collapsed\":true,\"items\":[{\"text\":\"Mybatis\",\"link\":\"/Mybatis&MybatisPlus/Mybatis\"},{\"text\":\"MybatisPlus\",\"link\":\"/Mybatis&MybatisPlus/MybatisPlus\"},{\"text\":\"JPA\",\"link\":\"/Mybatis&MybatisPlus/JPA\"}]},{\"text\":\"Git & ChatGPT\",\"collapsed\":true,\"items\":[{\"text\":\"Git\",\"link\":\"/5、运维/Git\"},{\"text\":\"Github\",\"link\":\"/5、运维/Github\"},{\"text\":\"ChatGPT\",\"link\":\"/5、运维/ChatGPT\"},{\"text\":\"Jenkins\",\"link\":\"/5、运维/Jenkins\"},{\"text\":\"Netty\",\"link\":\"/5、运维/Netty\"}]},{\"text\":\"数据库\",\"collapsed\":true,\"items\":[{\"text\":\"MySQL\",\"collapsed\":true,\"items\":[{\"text\":\"MySQL基础\",\"link\":\"/2、数据库/MySQL/MySQL核心/基础\"},{\"text\":\"MySQL进阶\",\"link\":\"/2、数据库/MySQL/MySQL核心/进阶\"},{\"text\":\"MySQL优化\",\"link\":\"/2、数据库/MySQL/MySQL核心/优化\"},{\"text\":\"MySQL设计\",\"link\":\"/2、数据库/MySQL/MySQL核心/设计\"},{\"text\":\"MySQL运维\",\"link\":\"/2、数据库/MySQL/MySQL核心/运维\"},{\"text\":\"分库分表\",\"link\":\"/2、数据库/MySQL/分库分表\"}]},{\"text\":\"Redis\",\"collapsed\":true,\"items\":[{\"text\":\"Redis基础\",\"link\":\"/2、数据库/Redis/Redis基础\"},{\"text\":\"Redis优化\",\"link\":\"/2、数据库/Redis/Redis优化\"},{\"text\":\"Redis原理\",\"link\":\"/2、数据库/Redis/Redis原理\"},{\"text\":\"Redis高级\",\"link\":\"/2、数据库/Redis/Redis高级\"},{\"text\":\"Redis实战\",\"link\":\"/2、数据库/Redis/Redis实战\"},{\"text\":\"本地缓存\",\"link\":\"/2、数据库/Redis/本地缓存\"}]},{\"text\":\"MongoDB\",\"collapsed\":true,\"items\":[{\"text\":\"MongoDB基础\",\"link\":\"/2、数据库/MongoDB/基础\"},{\"text\":\"MongoDB进阶\",\"link\":\"/2、数据库/MongoDB/整合\"}]},{\"text\":\"ElasticSearch\",\"collapsed\":true,\"items\":[{\"text\":\"ES基础\",\"link\":\"/2、数据库/ElasticSearch/1、ES基础\"},{\"text\":\"ES高级\",\"link\":\"/2、数据库/ElasticSearch/3、ES高级\"}]},{\"text\":\"InfluxDB\",\"link\":\"/2、数据库/influxdb\"},{\"text\":\"Neo4j\",\"link\":\"/2、数据库/Neo4j\"}]},{\"text\":\"高并发 & 秒杀 & 分布式\",\"collapsed\":true,\"items\":[{\"text\":\"分布式理论\",\"link\":\"/三高/分布式\"},{\"text\":\"分布式锁\",\"link\":\"/4、微服务/必备/分布式锁\"},{\"text\":\"秒杀\",\"link\":\"/三高/秒杀\"},{\"text\":\"高可用\",\"link\":\"/三高/高可用\"},{\"text\":\"高并发\",\"link\":\"/三高/高并发\"}]},{\"text\":\"云原生\",\"collapsed\":true,\"items\":[{\"text\":\"Docker\",\"link\":\"/云原生/Docker\"},{\"text\":\"K8S\",\"link\":\"/云原生/K8S\"}]},{\"text\":\"可视化 & 监控\",\"collapsed\":true,\"items\":[{\"text\":\"监控基础\",\"link\":\"/可视化 & 监控/监控基础\"},{\"text\":\"监控进阶\",\"link\":\"/可视化 & 监控/监控进阶\"},{\"text\":\"可视化大屏\",\"link\":\"/可视化 & 监控/可视化大屏\"},{\"text\":\"Zabbix\",\"link\":\"/可视化 & 监控/Zabbix\"}]},{\"text\":\"学前端\",\"collapsed\":true,\"items\":[{\"text\":\"HTML+CSS\",\"collapsed\":true,\"items\":[{\"text\":\"HTML基础\",\"link\":\"/1、学前端/1、HTML+CSS/HTML基础\"},{\"text\":\"CSS基础\",\"link\":\"/1、学前端/1、HTML+CSS/CSS基础\"},{\"text\":\"网页进阶\",\"link\":\"/1、学前端/1、HTML+CSS/网页进阶\"}]},{\"text\":\"JS+TS\",\"collapsed\":true,\"items\":[{\"text\":\"JS基础\",\"link\":\"/1、学前端/2、JS+TS/JS 基础\"},{\"text\":\"JS进阶\",\"link\":\"/1、学前端/2、JS+TS/JS 进阶\"},{\"text\":\"ES6基础\",\"link\":\"/1、学前端/2、JS+TS/ES6 基础\"},{\"text\":\"ES6进阶\",\"link\":\"/1、学前端/2、JS+TS/ES6 进阶\"},{\"text\":\"TS基础\",\"link\":\"/1、学前端/2、JS+TS/TypeScript\"}]},{\"text\":\"NodeJS\",\"collapsed\":true,\"items\":[{\"text\":\"Node基础\",\"link\":\"/1、学前端/4、Node/基础篇\"},{\"text\":\"Node进阶\",\"link\":\"/1、学前端/4、Node/进阶篇\"},{\"text\":\"项目实战\",\"link\":\"/1、学前端/4、Node/项目实战\"}]},{\"text\":\"Vue\",\"collapsed\":true,\"items\":[{\"text\":\"Vue3进阶\",\"link\":\"/1、学前端/3、Vue/Vue3/Vue3进阶\"},{\"text\":\"Vue3高级\",\"link\":\"/1、学前端/3、Vue/Vue3/Vue3高级\"},{\"text\":\"Vue3新语法\",\"link\":\"/1、学前端/3、Vue/Vue3/Vue3新语法\"},{\"text\":\"项目实战\",\"link\":\"/1、学前端/3、Vue/Vue2/Vue2项目\"}]},{\"text\":\"小程序\",\"collapsed\":true,\"items\":[{\"text\":\"小程序基础\",\"link\":\"/1、学前端/5、小程序/微信小程序\"},{\"text\":\"小程序优化\",\"link\":\"/1、学前端/5、小程序/小程序优化\"},{\"text\":\"uniapp\",\"link\":\"/1、学前端/5、小程序/uniapp\"},{\"text\":\"项目实战\",\"link\":\"/1、学前端/5、小程序/小程序项目\"}]}]},{\"text\":\"计算机基础\",\"collapsed\":true,\"items\":[{\"text\":\"数据结构\",\"link\":\"/计算机基础/数据结构/基础篇\"},{\"text\":\"操作系统\",\"link\":\"/计算机基础/计算机基础/操作系统\"},{\"text\":\"设计模式\",\"link\":\"/计算机基础/设计模式/基础篇\"},{\"text\":\"计算机网络\",\"link\":\"/计算机基础/计算机网络/网络基础\"},{\"text\":\"UML\",\"link\":\"/计算机基础/设计模式/UML\"},{\"text\":\"LeetCode\",\"link\":\"/计算机基础/算法/LeetCode\"}]},{\"text\":\"项目实战\",\"collapsed\":true,\"items\":[{\"text\":\"云尚办公\",\"collapsed\":true,\"items\":[{\"text\":\"基础篇\",\"link\":\"/项目实战/云尚办公/基础篇\"}]},{\"text\":\"小兔鲜\",\"collapsed\":true,\"items\":[{\"text\":\"基础篇\",\"link\":\"/项目实战/小兔鲜/基础篇\"},{\"text\":\"进阶篇1\",\"link\":\"/项目实战/小兔鲜/进阶篇1\"},{\"text\":\"进阶篇2\",\"link\":\"/项目实战/小兔鲜/进阶篇2\"}]},{\"text\":\"地图\",\"collapsed\":true,\"items\":[{\"text\":\"基础篇\",\"link\":\"/项目实战/百度地图/基础篇\"},{\"text\":\"进阶篇\",\"link\":\"/项目实战/百度地图/进阶篇\"}]},{\"text\":\"苍穹外卖\",\"collapsed\":true,\"items\":[{\"text\":\"进阶篇\",\"link\":\"/项目实战/苍穹外卖/进阶篇\"}]},{\"text\":\"黑马头条\",\"collapsed\":true,\"items\":[{\"text\":\"基础篇\",\"link\":\"/项目实战/黑马头条/基础篇\"},{\"text\":\"进阶篇\",\"link\":\"/项目实战/黑马头条/进阶篇\"},{\"text\":\"进阶篇2\",\"link\":\"/项目实战/黑马头条/进阶篇2\"},{\"text\":\"高级篇\",\"link\":\"/项目实战/黑马头条/高级篇\"}]},{\"text\":\"支付\",\"link\":\"/项目实战/支付\"},{\"text\":\"项目推荐\",\"link\":\"/项目实战/项目推荐\"}]},{\"text\":\"团队成员\",\"link\":\"/team\"}],\"siteTitle\":\"任硕的文档\",\"logo\":\"/Vue.png\",\"nav\":[{\"text\":\"Java学前端\",\"items\":[{\"items\":[{\"text\":\"HTML+JS\",\"link\":\"/Java学前端/HTML+JS\"},{\"text\":\"CSS\",\"link\":\"/Java学前端/CSS\"},{\"text\":\"Vue2+组件\",\"link\":\"/Java学前端/Vue2+组件\"},{\"text\":\"Vue3+组件\",\"link\":\"/Java学前端/Vue3+组件\"},{\"text\":\"React\",\"link\":\"/Java学前端/React\"}]}],\"activeMatch\":\"/Java/\"},{\"text\":\"软件测试\",\"items\":[{\"items\":[{\"text\":\"测试基础\",\"link\":\"/软件测试/测试基础\"},{\"text\":\"压力测试\",\"link\":\"/软件测试/压力测试\"}]}]},{\"text\":\"多线程\",\"items\":[{\"items\":[{\"text\":\"基础篇\",\"link\":\"/并发 & 多线程/基础篇\"},{\"text\":\"进阶篇\",\"link\":\"/并发 & 多线程/并发完善\"}]}]},{\"text\":\"开发工具\",\"items\":[{\"items\":[{\"text\":\"Chrome\",\"link\":\"/IDEA/Chrome\"},{\"text\":\"IDEA基础\",\"link\":\"/IDEA/IDEA基础\"},{\"text\":\"IDEA插件\",\"link\":\"/IDEA/IDEA插件\"},{\"text\":\"VS Code\",\"link\":\"/IDEA/VS Code\"}]}]},{\"text\":\"消息中间件\",\"items\":[{\"items\":[{\"text\":\"RabbitMQ\",\"link\":\"/消息中间件/RabbitMQ\"},{\"text\":\"RocketMQ\",\"link\":\"/消息中间件/RocketMQ\"},{\"text\":\"Kafka\",\"link\":\"/消息中间件/Kafka\"},{\"text\":\"Canal\",\"link\":\"/消息中间件/Canal\"}]}]}],\"socialLinks\":[{\"icon\":\"github\",\"link\":\"https://github.com/renshuo123/renshuo123.github.io\"},{\"icon\":\"twitter\",\"link\":\"#\"},{\"icon\":{\"svg\":\"<svg t=\\\"1676028692954\\\" class=\\\"icon\\\" ...</path></svg>\"},\"link\":\"https://github.com/\"}]},\"locales\":{},\"scrollOffset\":90,\"cleanUrls\":false}");</script>
    
  </body>
</html>